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,
--
Matt