:SOCKETS
This is a package for CMUCL (and soon SBCL) which implements a lot
of what is commonly known as the BSD sockets API, as FFI calls to the
C library. I don't know what the exact scope of "BSD sockets" is, but
I've taken all the bits that make sense. Development and testing thus
far has all been done on ix86 GNU/Linux; feedback from users of other
platforms is solicited
Motivation
The motive behind developing another sockets support library is twofold:
- I wish to have the full flexibility of the C interface available
from a sensible language. To take a fairly commonly-used example, the
existing CMUCL interface does not allow a server to set the socket
option SO_REUSEADDR - this is essential for stopping and
quickly restarting a server on the same port (e.g. a web server) and
additionally its lack will drive a developer crazy quite fast during
development. Other features which I wish to be able to support
include UDP servers, querying the path MTU, toggling the Nagle
algorithm and so on
- SBCL (a new free Common Lisp born of CMUCL) has the same foreign
function interface but no socket library at all. I hope that this may
in time become the standard (or most commonly used) socket library for SBCL.
Design Principles
The initial ideas for API design were provided by Perl's
IO::Socket functions, but the perspective shifted somewhat
during design:
- The code uses a clean design that allows it not to be
cluttered with #+foo directives for different platforms. It
gets structure layouts and symbolic constants from a C program which
must be built and run at installation time.
- Each major function in :SOCKETS corresponds to a
function in the socket API. This makes the system manual pages useful
when coding in Lisp.
- The worst excesses of type punning in the C API have been
removed. Integers "in network byte order", for example, have been
replaced with vectors of (unsigned 8) to make it clear that we're
talking about a sequence of bytes.
- Error handling is uniformly handled using the Common Lisp
condition system. If any of the underlying socket calls returns
indicating that an error happened, a condition whose supertype is
SOCKET-ERROR is thrown. The exact condition type depends
on the error returned; there is intended to be one condition per
interesting errno value.
- Names of functions, constants, errors etc are almost always based
on the equivalent C names, but with abbreviations expanded to the full
name. For example, EPROTONOTSUPP becomes
protocol-not-supported-error and ENETUNREACH is
network-unreachable-error
Implementation
Implementation is still happening. You can find a window onto the
current CVS repository at http://loaclhost.telent.net/cgi-bin/cvsweb/telent/sockets, and often an
update of what's changed lately at http://www.advogato.org/person/dan/
As of Mon Mar 6 00:51:21 GMT 2000, the system exists to the extent
that noddy TCP clients and servers can both be implemented, but is not
yet at the point where it has much advantage over the existing CMUCL socket
code. Development directions actively being pursued right now can be
seen by looking at the TODO file