Hi all,
In the spirit of "release early, release often" I have elected to make a Darcs repository available which will allow you to track the progress of Gamsock. You can access it by doing:
darcs get http://ii-0-ii.com/parodycheck/repos/gamsock
Notes:
* Documentation is nonexistent but you are welcome to peruse and bang on the code.
* Actual socket calls (socket, bind, connect, send, recv, etc.) tend to bear their POSIX names. (Change this?)
* Sockets and sockaddrs are opaque types. Sockaddrs have constructors for each of the different address families, which convert the parameters into the appropriate sockaddr data; and accessors to convert the other way. (Should I give people access to the raw sockaddr bits, as sb-bsd-sockets for SBCL does?)
* Calls which on the C side take enums can take either numeric values or symbol constants on the Scheme side. E.g., you can do (socket PF_INET SOCK_STREAM 0) or (socket 'inet 'stream 0). (Should I favor one over the other?)
* Likewise, calls which on the C side take the bitwise inclusive OR of a set of flags, can take a list of symbols instead on the Scheme side.
* Currently there are no protocol names specified. For an inet socket you may specify 0 as the protocol, in which case the protocol will be selected by the socket type (SOCK_STREAM, SOCK_DGRAM, etc.)
* Unix-domain and IPv4 sockets (TCP and UDP) should be supported. Only TCP IPv4 sockets have been thoroughly tested. One can initiate and accept connections, send, and receive.
* IP addresses (for make-inet-sockaddr) take the form of a four-element u8vector. You may also pass in a string (e.g., "127.0.0.1"). This latter option is kind of arbitrary and may disappear, or be moved to a facility to do DNS lookups when it becomes available. Port numbers are fixnums.
* You can only send u8vectors of data at this time. You also get a u8vector back when you do recv.
* There will be a facility (not yet implemented) that will let you wrap stream sockets at least with Gambit ports, mimicking the facility of tcp-sockets already in place in Gambit.
* This has been tested on 4.0b17. YMMV on any other version (including yesterday's release).
* If there is an error, an os-exception will be raised with the error code of the exception set to errno. (Change this? Make the errors meaningful, platform-agnostic?)
* For the time being, Gamsock works on Linux only. Currently on BSD, Gamsock compiles but when you try to bind a socket to an address, it raises an os-exception with code EINVAL. I think it has to do with the fact that OpenBSD sockaddrs have an additional sa_len element that Linux sockaddrs lack. More testing is necessary.
I hope this is interesting or useful to some of you out there. Please share with me your thoughts and suggestions.
--Jeff
Afficher les réponses par date