Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Add a Mercury interface to the C function getaddrinfo. getaddrinfo
superceeds gethostbyname and getservbyname. It is reenterant and also makes
it easier to support IPv6 amoung other things. Other predicates in netdb.m
should be written in terms of getaddrinfo.
extras/net/getaddrinfo.m:
As above.
extras/net/netdb.m:
Add predicates that use getaddrinfo to perform lookups.
extras/net/types.m:
Add predicates to convert to and from the raw values for family and
socktype.
extras/net/test_lookups.m:
extras/net/Makefile:
Add a test program.
.gitignore:
This .gitignore file was causing git to ignore the Mercury.options file
in net/extras. A leading slash in .gitignore patterns matches the start
of a path, this allows us to ignore these patterns when they're only in
the root directory.
extras/net/Mercury.options:
Work around a Mercury bug.
Add this missing file.
extras/net/sockets.m:
Add read and write predicates.
extras/net/streams.m:
New file containing implementations of stream typeclasses.
extras/net/net.m:
Include the new streams module.
extras/net/echo.m:
Use the new streams typeclass instances to complete the implementation
of the echo server. It works one byte at a time (making it slow) and
will not handle simultanious connections.
extras/net/Makefile:
Add clean target
This library had been neglected for a while and came to my attention when it
used deprecated (or at least old) C interfaces rather than newer reentrant
ones. I've started to improve this library by giving a more typesafe and
Mercury-esque API, using only reentrant C functions, and eventually adding
support for more protocols, (eg: IPv6 and UDP) better integration with
Mercury's io module and generally making it easier to use.
What's working now:
+ creating sockets,
+ binding and listening,
+ connecting (untested),
+ accepting,
+ closing.
+ The interface is generally more type-safe, using new types suck as
"socket" and "address" rather than "int" and "c_pointer".
What's not working/incomplete:
+ I havn't yet touched the tcp.m module, but I intend to remove it and
create a new high-level interface for various protocols.
+ Any kind of reading / writing over sockets at all.
+ Name lookups.
+ A lot of the interface is incomplete / missing useful functions and
predicates.
This is a work in progress.
Makefile:
New Makefile.
README.md:
New Readme file.
net.m:
net is now a module containing the other modules as submodules.
sockets.m:
Many changes as described above.
netdb.m:
This new module contains host and other name lookups. Only service
lookups are currently implemented.
types.m:
Types shared by sockets.m and netdb.m.
echo.m:
An example echo server.
errno.m:
strerror functionality.
tcp.m:
Conform to changes in net.m.
Estimated hours taken: 0.5
Branches: main
extras/README:
Document that streams has been depreceated.
extras/net/net.m:
extras/net/sockets.m:
extras/net/tcp.m:
A network binding to the streams interface.