axiom-developer
[Top][All Lists]
Advanced

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

[Axiom-developer] Re: [Gcl-devel] GCL Socket questions


From: Camm Maguire
Subject: [Axiom-developer] Re: [Gcl-devel] GCL Socket questions
Date: 28 Apr 2004 21:58:03 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

OK here is a start:

1) Install netcat
2) in a shell, do nc -l -p 1920
3) In gcl osmehwere else, (setq s (si::socket 1920 :host "localhost"))
4) (format s "hello%") ; should appear in netcat window
5)  Type "there <cr>" in netcat window
6) In gcl (read-line s) ; (should get "there")
7) In gcl (close s) ; should terminate netcat.

Take care,

Chris Hall <address@hidden> writes:

> 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:
> 
>   * SI::OPEN-NAMED-SOCKET, then SI::ACCEPT-SOCKET-CONNECTION using
>     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
> SI::SOCKET.
> 
> 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
> interested.
> 
> 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.
> 
> 
> However,
> ------------ snip -------------
> 
>  >(setf skt (si::socket 4100 :host "localhost" :async t))
> #<two-way stream 08830ee8>
> 
> >(read-line skt)
> ""
> T
> 
> ------------ /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
> STRING-CHAR.
> 
> 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 
> 
> T
> ------------ /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)
> (LAMBDA-BLOCK SOKSRV (STRM) (FORMAT STRM (READ-LINE STRM)))
> 
> >(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.
> 
> Aloha,
> +Chris
> 
> -- 
> Good judgment comes from experience. Experience comes from bad
> judgment.
> - Jim Horning
> 
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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