Search code examples
socketsudpcommon-lispccl

Problems sending UDP with CCL


when I try to send a message as follow:

(let* ((temp-buffer message)
 (out-vector (make-array (length temp-buffer) 
             :element-type'(unsigned-byte 8)
             :initial-contents temp-buffer))
 (s (ccl:make-socket :remote-host host :remote-port port :type :datagram )))
(ccl:send-to s out-vector (length out-vector))
(ccl::close s))

I get the following error:

on #<CCL::UDP-SOCKET #x302000D9FCFD> : 
Socket is already connected (error #56) during sendto

Initially, this code was effective. Could anyone explain this error message and how to solve it. Thanks for any help.


Solution

  • This seems to work.

    (let* ((temp-buffer message)
           (out-vector (make-array (length temp-buffer)
                                   :element-type'(unsigned-byte 8)
                                   :initial-contents temp-buffer))
           (s (ccl:make-socket :type :datagram)))
      (ccl:send-to s out-vector (length out-vector) :remote-host host :remote-port port)
      (ccl::close s))