David Rager | 8 Sep 20:46

[OpenMCL/CCL Devel] Send and receive data via CCL sockets

Hello,

Please excuse my extremely naive question.  I've been reading many
documents over the last week and have yet to find a definitive way to
send and receive data via sockets in CCL.  How does one send/receive
data over TCP in CCL?  I got the OpenMCL REPL from 2004ish working (a
rather nice piece of work btw).  But, now I'd like to do more advanced
things like send data back instead of a string.

As a starting point, here's some of what I've been doing:

In LISP session 0:
(setf *socket?* (make-socket :local-host "127.0.0.1" :local-port 24365
:remote-host "127.0.0.1" remote-port 23459 :connect :passive :type
:stream :reuse-address t))

In LISP session 1:
(setf *socket?* (make-socket :local-host "127.0.0.1" :local-port 23459
:remote-host "127.0.0.1" remote-port 24365 :connect :active :type
:stream :reuse-address t))
(format *socket* "hello")

In LISP session 0:
(read-line *socket* nil nil)
; now I hit an error about how *socket* isn't of type stream.  How do
I make *socket* of type stream?

I'm almost positive reuse-address is optional (I think t is the default?).

Thanks!
(Continue reading)

Karsten Poeck | 8 Sep 21:42

Re: [OpenMCL/CCL Devel] Send and receive data via CCL sockets

Hello,
I use the following:
(defun %make-client-socket (host &key port)
  (ccl:make-socket :remote-host host 
                   :remote-port port
                   :type :stream
                   :connect :active
                   :format :bivalent))

(defun %make-server-socket (&key port)
  (ccl:make-socket :local-port port
                   :type :stream
                   :connect :passive
         ;;; at least for debugging
         :nodelay t
         :backlog 5
         :reuse-address t
                   :format :bivalent))

(defun %wait-for-connection (socket)
  (let ((stream (ccl:accept-connection socket :wait t)))
    stream))

Listener 1
(setq der ( %make-server-socket :port 8000))
-> #<CCL::LISTENER-SOCKET #x3000417DFBCD>

( %wait-for-connection der)
 -> Blocks

(Continue reading)


Gmane