rshapiro@arris.com (Richard Shapiro) (01/24/91)
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 -- rs/rshapiro@arris.com
barmar@think.com (Barry Margolin) (01/24/91)
In article <1991Jan23.215610.1176@arris.com> rshapiro@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. barmar@think.com {uunet,harvard}!think!barmar
layer@Franz.COM (Kevin Layer) (01/25/91)
Allegro CL has an implemention of this in the function OPEN-NETWORK-STREAM: (defun open-network-stream (&key host port socket-file) "Open a stream to a port, which is a TCP/IP communication channel. There are two types of ports supported, UNIX and INTERNET domain. The domain is chosen based on the keyword arguments supplied: For internet domain: HOST is the string host name or an integer internet address. PORT is the string service name or a port number. For Unix domain: SOCKET-FILE is the string pathname of the socket." ) The source code for this is distributed with our emacs-lisp interface (there was a recently release, posted to gnu.emacs.sources). It uses our underlying stream implementation, but it might be useful if Lucid provides a similar substrate. -- Kevin Layer, Franz Inc. 1995 University Avenue, Suite 275 layer@Franz.COM (internet) Berkeley, CA 94704 uunet!franz!layer (uucp) Phone: (415) 548-3600; FAX: (415) 548-8253