We are in need of a new more versatile TCP/socket library. This little experiment could be the start of it.
I've chosen for the sockets to be overloaded so that you don't need to pass socket type arguments or flags all the time and the process is less error prone.
This could easily combine with a
select class because access to the underlying file descriptor (or HANDLE in the case of windows) is readily available.
System._Socket contains the low level access functions and macro definitions such as AF_INET System.Socket reexports them together with the class definitions System.Socket.* contains socket types, some can be in OS-Independent (e.g. ipv4, ipv6) and some are OS specific (e.g. Unix sockets).
A test client and server can be found in
src/examples/socket that is tested on windows and linux.
The library is very bare bones but that leaves room for abstractions to be made on top of it.
It is in no way finished or thoroughly tested but it seemed more logical to do this in steps.
Maybe we can use this thread to discuss a
select interface. (#40)
Todo before merging
- free all allocs, also when an error occurred
- check if all mallocs succeed
- handle unknown error codes in the case
- decide on names
- change names
- remove int parameters for flags