SBCL Sockets: Reuse Address

The challenge sockopt-reuse-addressdoes not seem to have any effect.

(setf socket (make-instance 'sb-bsd-sockets:inet-socket 
                            :type type :protocol protocol)
(setf (sb-bsd-sockets:sockopt-reuse-address socket) t)
(setf (sb-bsd-sockets:non-blocking-mode socket) t)
(sb-bsd-sockets:socket-bind socket ip port)
(sb-bsd-sockets:socket-listen socket backlog)

An attempt to bind to the same port causes the following error:

Socket error in "bind": EADDRINUSE (Address already in use)
   [Condition of type SB-BSD-SOCKETS:ADDRESS-IN-USE-ERROR]

What am I doing wrong?

+3
source share
2 answers

You can try IOLib , the function make-socketseems to support the keyword :reuse-address. As far as I remember, IOLIB does not use the built-in network functions of the Lisp implementation, so it can work even without SBCL that supports this function directly.

I have not tested it yet.

+2
source

See this thread in sbcl-help.

+1
source

All Articles