Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i retrieve the address of the socket peer in Lisp with cl-async

I am experimenting with cl-async using SBCL, i cannot figure out how to retrieve the IP address of the socket that I'm communicating on.

I'm using SBCL 1.4.16 on gnu-linux with telent 1.9.4

The ADDRESS slot in the socket object appears unbound, and I failed at trying to extracting from the lower level libuv binding

I am using the default example from the docs with the addition of the lines between the comments below from http://orthecreedence.github.io/cl-async/examples

(defun my-echo-server ()
    (format t "Starting server.~%")
    (as:tcp-server nil 9003  ; nil is "0.0.0.0"
        (lambda (socket data)
            (describe socket)
            ;; echo the data back into the socket
           (as:write-socket-data socket data))
        (lambda (err) (format t "listener event: ~a~%" err)))
  ;; catch sigint
  (as:signal-handler 2 (lambda (sig) (declare (ignore sig)) (as:exit-event-loop))))

(as:start-event-loop #'my-echo-server)

The output as soon as i connect and send something with netcat or telnet is:

#<CL-ASYNC:TCP-SOCKET {1004DC0BF3}>
  [standard-object]

Slots with :INSTANCE allocation:
  C                              = #.(SB-SYS:INT-SAP #X7F3EEC021490)
  DATA                           = NIL
  CLOSED                         = NIL
  DRAIN-READ-BUFFER              = T
  ADDRESS                        = #<unbound slot>
  BUFFER                         = #S(FAST-IO:OUTPUT-BUFFER..
  BUFFERINGP                     = NIL
  CONNECTED                      = T
  DIRECTION                      = :IN

And the ADDRESS slot is surprisingly unbound...

Has anybody encountered this problem?

like image 772
Bandoos Avatar asked Nov 06 '22 17:11

Bandoos


1 Answers

I found an issue on the project’s repo that presents the same problem, so I am closing the question since there appears to be no clean solution. For my project I’m going to follow the suggestion of the author of putting a proxy in front of the service. issue

like image 73
Bandoos Avatar answered Nov 16 '22 15:11

Bandoos