I've been trying out iolib yesterday, and unfortunately couldn't find any proper documentation. I therefore started reading the source. I've noticed net.sockets:make-socket which appears to be the public interface to create a new socket.
Using this function without specifying :connect resulted in an :active socket, which I noticed the API wouldn't later let me bind. I thus created a :passive one, although I noticed that this did not let me specify any address or port to bind to and would already bind(2) and listen(2).
I've seen some other user of iolib bind the port afterwards using ensure-hostname and bind-address, which I decided to try even though this would result in a potential race condition (security-wise). However, this reminded me that NetBSD won't allow to bind a TCP socket already bound and listen'd:
And according to bind(2): [EINVAL] The socket is already bound to an address.
Thus, a lower-level API would be required to either change the :active/:passive state of a socket (so that an :active one may be created and then changed to a :passive so manual bind+listen calls could be done) or for make-socket to allow specifying an address/port to bind to before the code binds+listens.
Any suggestions? Perhaps that since :active is the default, anything else for :connect could be checked to see if it consists of an address/port to bind to, and if so use that? Or the addition of a new key like :address?
Thanks,
On Mon, 2009-01-26 at 05:40 -0500, Matthew Mondor wrote:
I've been trying out iolib yesterday, and unfortunately couldn't find any proper documentation. I therefore started reading the source. I've noticed net.sockets:make-socket which appears to be the public interface to create a new socket.
Iolib's make-socket is largely compatible with Allegro's so you can find documentation at http://www.franz.com/support/documentation/current/doc/operators/socket/make...
Using this function without specifying :connect resulted in an :active socket, which I noticed the API wouldn't later let me bind. I thus created a :passive one, although I noticed that this did not let me specify any address or port to bind to and would already bind(2) and listen(2).
You can specify address and port with the keywords :local-host and :local-port. To obtain an unbound socket, use :local-host nil .
On Mon, 26 Jan 2009 15:21:42 +0100 Stelian Ionescu stelian.ionescu-zeus@poste.it wrote:
On Mon, 2009-01-26 at 05:40 -0500, Matthew Mondor wrote:
I've been trying out iolib yesterday, and unfortunately couldn't find any proper documentation. I therefore started reading the source. I've noticed net.sockets:make-socket which appears to be the public interface to create a new socket.
Iolib's make-socket is largely compatible with Allegro's so you can find documentation at http://www.franz.com/support/documentation/current/doc/operators/socket/make...
Nice to know (I'm relatively new to Common Lisp and only have used SBCL).
You can specify address and port with the keywords :local-host and :local-port. To obtain an unbound socket, use :local-host nil .
This indeed worked great. Thanks!
On Mon, 26 Jan 2009 15:21:42 +0100 Stelian Ionescu stelian.ionescu-zeus@poste.it wrote:
Iolib's make-socket is largely compatible with Allegro's so you can find documentation at http://www.franz.com/support/documentation/current/doc/operators/socket/make...
Any particular reason CLOSE is not external? (i.e. requireing net.sockets::close rather than net.sockets:close or close)...
Thanks again,
On Mon, 2009-01-26 at 16:32 -0500, Matthew Mondor wrote:
On Mon, 26 Jan 2009 15:21:42 +0100 Stelian Ionescu stelian.ionescu-zeus@poste.it wrote:
Iolib's make-socket is largely compatible with Allegro's so you can find documentation at http://www.franz.com/support/documentation/current/doc/operators/socket/make...
Any particular reason CLOSE is not external? (i.e. requireing net.sockets::close rather than net.sockets:close or close)...
that should be cl:close
On Mon, 26 Jan 2009 22:37:32 +0100 Stelian Ionescu stelian.ionescu-zeus@poste.it wrote:
that should be cl:close
This works fine, thanks again