Oddi T
Oddi T

Reputation: 41

Trouble with usocket in Clozure CL

I can't get USOCKET to work under CCL, even though the very same code works on SBCL and CCL's built-in sockets work ok.

This snippet works in SBCL:

(let* ((sd (usocket:socket-connect "localhost" 1875))
       (st (usocket:socket-stream sd)))
  (write-line (format nil "hello from ~A + usocket." (lisp-implementation-type)) st)
  (finish-output st))

but on CCL it signals a USOCKET:CONNECTION-REFUSED-ERROR.

I don't think it's a firewall issue because (a) the same problem occurs on both my Windows and Linux machines, and it works under SBCL; and (b) it works when I use CCL's built-in sockets:

(with-open-socket (socket :address-family :internet
                          :type :stream
                          :remote-host "localhost"
                          :remote-port 1875
                          :reuse-address t)
  (format socket "~A." (format nil "Hello from ~A + native ccl sockets." (lisp-implementation-type)))
  (force-output socket))
;; works!

So now I'm stumped as to why usocket functions can't access the network in CCL, but the same usocket code works in SBCL and CCL's built-in socket library can access the same address/host without any problem. I've experimented with different ports, addresses, even UDP sockets, but usocket just doesn't work in CCL on either of my machines. And Google search doesn't show this being a common problem.


edit: So I decided to investigate and see if there is actually a UDP socket open. I checked netstat (Windows) and ss -u -pa (linux) and sure enough there is a UDP socket open in ccl even when it's unreachable.

This is true on both my Windows and Linux machines. I don't know why it's doing this, but I think usocket trying to force IPv6 under CCL is the problem.

Is there some way I can force it to use IPv4? I've tried making my UDP socket bind to "127.0.0.1" instead of "localhost", but it signals this condition:

The condition Address family for hostname not supported (error #-9) during nameserver operation in getaddrinfo occurred with errno: 0.
   [Condition of type USOCKET:UNKNOWN-ERROR]

I'm not sure if my system is misconfigured somehow, or if the problem lies within usocket or ccl.


edit: Solved, I was using an outdated version of usocket, just had to (ql:update-all-dists)

Upvotes: 2

Views: 95

Answers (0)

Related Questions