From: Richard Shapiro
Subject: TCP i/o in Sun Lucid
Date: 
Message-ID: <1991Jan23.215610.1176@arris.com>
Is there a simple way to do tcp i/o in Sun Lucid? 

Ideally, I'd like something like this:

 (with-open-tcp-stream (stream :address address :port port :direction :io)
   (write-string "..." stream)
   .
   .
   .
   (force-output stream)
   (read-line stream))

where address is an internet style address ("128.10.15.20" or
whatever) of the machine I want to contact, and port is the port
number on that machine which handles the service I want.

Does Sun Lucid provide a nice macro like WITH-TCP-STREAM, or even a
simple OPEN-TCP-STREAM function? Perhaps they've generalized OPEN so
that the "file" argument can be a tcp address+port specification?  Or
am I stuck doing lower level Unix socket i/o?

Thanks --

···········@arris.com
From: Barry Margolin
Subject: Re: TCP i/o in Sun Lucid
Date: 
Message-ID: <1991Jan23.234438.9516@Think.COM>
In article <·····················@arris.com> ········@arris.com (Richard Shapiro) writes:
>Is there a simple way to do tcp i/o in Sun Lucid? 
...
>Does Sun Lucid provide a nice macro like WITH-TCP-STREAM, or even a
>simple OPEN-TCP-STREAM function? Perhaps they've generalized OPEN so
>that the "file" argument can be a tcp address+port specification?  Or
>am I stuck doing lower level Unix socket i/o?

Lucid has nothing built-in specific to TCP.  MAKE-LISP-STREAM can be used
to create a Lisp stream connected to a Unix file descriptor.  You'll have
to use the Unix socket or TLI library (presumably via the foreign function
interface) to open the stream, but after calling MAKE-LISP-STREAM you can
then use Common Lisp operations.  OPEN-TCP-STREAM would call the foreign
function and then call MAKE-LISP-STREAM; WITH-OPEN-TCP-STREAM would
presumably package the call to OPEN-TCP-STREAM with a WITH-OPEN-STREAM.

CLX has to do this, so you might want to look at how it does it.  Look at
the source for the functions XLIB::OPEN-TCP-STREAM (in dependent.lisp) and
XLIB::CONNECT-TO-SERVER (this is a foreign function defined in socket.c as
connect_to_server).


--
Barry Margolin, Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar