[usocket-devel] Support for Server Connections
Erik Huelsmann
ehuels at gmail.com
Fri Oct 20 21:11:17 UTC 2006
> On 10/16/06, Nick Thomas <jesuswaffle at gmail.com> wrote:
> > A couple weeks ago, I hacked together the beginnings of a TCP server
> > socket implementation. It has documentation, but no tests. I wrote the
> > backend for SBCL, and it seems to be working fine.
> >
> > It doesn't support a lot of the requirements [that Erik] discussed. It
> > doesn't support setting socket options, and it only works with IPv4.
> > However, it might be useful as a basis for further work. Patch attached.
Thanks! ;-)
I've copied parts of the patch into this mail below and have given
comments inline.
[From README]
+ - usocket-server (class)
You decided to create a class without inheriting from the existing
usocket class. I'd like to inherit from some superclass, so that we
can at least use get-local-name for both server sockets and stream
sockets: when a server is created with a :port 0 (any port), it may be
usefull to be able to query the assigned port number afterwards...
Obviously, we can't inherit every behaviour, because there's no remote
address which can be queried. We'd have to find a way to work around
that. Maybe by creating a new superclass (bound-usocket or something
like it) which only has a local address.
+ - server-listen (function) [ to create a passive/server socket ]
+ server-listen port &optional (host *default-host*)
+ (backlog *default-backlog-size*)
+ where `host' is a vectorized ip
+ or a string representation of a dotted ip address
+ or a hostname for lookup in the DNS system
+ `host' and `backlog' are ignored on systems that do not support
+ specifying them
+ - server-accept (method)
+ server-accept server-socket
+ returns a newly connected usocket
That all looks good.
+ - server-close (method)
+ server-close server-socket
well, we could inherit this one too, if we were to create the right
inheritance structure.
+ - *default-host* (variable)
+ the default host to bind server sockets to. 0.0.0.0 by default.
+ - *default-backlog-size* (variable)
+ the default connection backlog size. 16 by default.
Ah, but supposedly, some systems only support 5 as the default value.
Next to that, there's 8 in the actual definition :-)
I like how your patch makes the server-accept function return a stream
related usocket.
bye,
Erik.
More information about the usocket-devel
mailing list