socketscommon-lispccl

make-socket error in Clozure Common Lisp


On CCL toplevel, running:

(make-socket :LOCAL-PORT 6666 :LOCAL-HOST "127.0.0.1")

OR

(make-socket :LOCAL-PORT 6666 :LOCAL-HOST (lookup-hostname "localhost"))

outputs the following:

> Error: There is no applicable method for the generic function:
>          #<STANDARD-GENERIC-FUNCTION CCL::SOCKADDR #x30200043F91F>
>        when called with arguments:
>          (NIL)
> While executing: #<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD (T)>, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Try calling it again
> Type :? for other options.

I can't make sense of the error (new to CL). What does it mean? And what am I doing wrong?


Solution

  • The problem in your code is that the key parameters provided to MAKE-SOCKET require the creation of an active TCP socket, and not a passive one (listener socket), as you have specified in a comment. This is because, by default, the key :connect, that specifies if the socket is active or passive, is assigned the value :active.

    The error message specifies that the system encountered a call to CCL:SOCKADDR with argument NIL, for which no method exists. So the reason is that a socket address is required but none is provided.

    By using Emacs with SLIME you could have found:

    1. the trace of the last calls on the stack: MAKE-SOCKET, that calls MAKE-TCP-SOCKET, that calls %SOCKET-CONNECT (that produces the error);

    2. the values of the variables inside each call, seeing for instance that inside the call to %SOCKET-CONNECT the parameter SOCKET-ADDRESS is NIL;

    3. the code of all the three functions, by inspecting it you could have found that MAKE-TCP-SOCKET require a socket-address, and if this is not provided as value to the key parameter :remote-address, a call to resolve address is made with remote-host and remote-port.