gcl-devel
[Top][All Lists]
Advanced

[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/0.14.2.91 (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 "127.0.0.1" :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 "127.0.0.1" :element-type 
'(unsigned-byte 8) :buffered nil))
*S*
[4]> *s*
#<IO UNBUFFERED SOCKET-STREAM (UNSIGNED-BYTE 8) 127.0.0.1:9999>

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

(making doubly sure it was output)

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

$ 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*)

-1

>(open-stream-p *s*)

T

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.

Regards,
Adam





reply via email to

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