[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] The new socket interface

From: Adam Warner
Subject: [Gcl-devel] The new socket interface
Date: Mon, 13 Dec 2004 17:58:02 +1300
User-agent: Pan/ (As She Crawled Across the Table (Debian GNU/Linux))

Hi Camm and all,

I have tried the new socket interface since you said last month it was
basically functional. On the client side it works. I can't get the
server side to work.

@(static defun socket (port &key host server async myaddr myport)
             HOST is a string then connection is made to that
                          ip or domain address.
            SERVER  A function to call if this is to be a server

            ASYNC  socket returned immideiately.  read or flush
                           will block till open if in non blocking mode
            MYADDR  client's ip address. Useful if have several
                                    net interfaces
            MYPORT  port to use on client side

I don't know what the function to call should look like so I've just
created a generic one so I can see what's going on:

(defun server-fn (&rest args)
  (print args))

(defparameter *s* (si:socket 9999 :host "" :server #'server-fn))

*s* => #<two-way stream 09264af8>

So I now have a two way stream.

Using CLISP I will connect to the server:

[3]> (defparameter *s* (socket:socket-connect 9999 "" :element-type 
'(unsigned-byte 8) :buffered nil))
[4]> *s*

And write a byte to GCL:
[5]> (write-byte 123 *s*)
[6]> (force-output *s*)

(making doubly sure it was output)

Using netstat -a | grep 9999 we see that one byte is yet to be copied by

$ netstat -a | grep 9999
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost.localdom:9999 *:*                     LISTEN
tcp        0      0 localhost.localdo:33481 localhost.localdom:9999 ESTABLISHED
tcp        1      0 localhost.localdom:9999 localhost.localdo:33481 ESTABLISHED

The byte isn't read by GCL:
>(read-byte *s*)


>(open-stream-p *s*)


Is there anything I'm doing wrong or is the interface simply incomplete?

BTW, for compatibility with other implementations it would be nice if a
SOCKET-ACCEPT style interface was provided in addition to the function
call interface.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]