[Top][All Lists]

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

[Gcl-devel] GCL Socket questions

From: Chris Hall
Subject: [Gcl-devel] GCL Socket questions
Date: 25 Apr 2004 07:14:55 -1000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

I'm using GCL 2.6.1 and Emacs 21.2.1 on Debian Woody w/2.2.25 kernel.

I'd really, really like to be able to use sockets in GCL, so I have
been trying things and 'using the source'.

First of all, it appears that there are two (at least) existing
approaches to sockets in GCL:

    the cons returned by OPEN-NAMED-SOCKET

  * SI::SOCKET, which returns a two-way stream (woot!), and may also
    be passed a 'server function' (woot-woot!) or may be used as a
    client to connect another process/host.

SI::SOCKET looks perfect for most of what I'd like to do in the short
term, while SI::OPEN-NAMED-SOCKET looks good for lower-level stuff.  I
was busy figuring out what to do with the cons it returned - looking
'fd-level' functions that might work - when I saw the earlier post
about "OUR-WRITE", thats when I started seriously looking into

FTR, I have problems getting the fd (the car of the cons returned by
OPEN-NAMED-SOCKET) to close properly when running in an inferior lisp
in Emacs.  SI::CLOSE-FD works at least in part, but netstat then shows
the port in a FINL-WAIT or CLOS-WAIT or some such - have to exit GCL
for the port to completely go away.

>From an xterm, or from an inferior lisp in Emacs,
------------ snip -------------

>(setf skt (si::socket 4100 :host "localhost"))
couldn't open socket:

------------ /snip ------------

and the process goes away.  In the xterm, we're back at the prompt.

The error message seems to originate from CreateSocket, defined in
o/nsocket.c and invoked from o/file.d 'socket' function, if anybody is

A not-so-minor-in-my-book nit: if I am reading CreateSocket right, the
"couldn't open socket:" message is returned both for a bind error
_and_ an address error, and tells us nothing about either.

------------ snip -------------

 >(setf skt (si::socket 4100 :host "localhost" :async t))
#<two-way stream 08830ee8>

>(read-line skt)

------------ /snip -------------

_seems_ to work OK.

Anyway, once one *does* get a nice two-way, string-char element stream
wrapped around a socket, what can one do?

STREAMP returns T on the stream, and STREAM-ELEMENT-TYPE indicates

I can connect to the port from telnet, and type, then try to do a
READ-LINE - in an inferior lisp, READ-LINE immediately returns an
empty string and NIL, whether or not telnet has sent anything; from
the xterm, it hangs until Ctrl-C'd.

If I try to FORMAT, WRITE-LINE etc.:

------------ snip -------------

>(format skt "Heloo, Chris!~%")
Error in FORMAT [or a callee]: error writing to socket: errno= 32

------------ /snip -------------

A little research seems to indicate errno 32 = EPIPE = broken pipe.

The inferior lisp process is still usable, but trying to CLOSE the
stream after a write gives us:

------------ snip -------------

>(close skt)
tried Clsing -1 ! as scoket 

------------ /snip -------------

This happens from the xterm as well.

I can't seem to get my own little server function working either:
(I am assuming here that the server function passed in is meant to
accept one argument - the stream?)

------------ snip -------------

>(symbol-function 'soksrv)

>(setf skt (si::socket 4100 :server (symbol-function 'soksrv)))
#<two-way stream 08832000>

------------ /snip -------------

and then telnetting in and typing, or using WRITE-LINE followed by
FINISH-OUTPUT doesn't seem to do anything either.

Any thoughts, suggestions, ideas will be welcome.


Good judgment comes from experience. Experience comes from bad
- Jim Horning

reply via email to

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