[comp.lang.lisp] How do I get and use input from a telnet session in Lisp?

bskendig@phoenix.Princeton.EDU (Brian Kendig) (05/28/90)

Here's the scenario: In my spare time (!) over the summer, I'm going
to try to write an artificial-intelligence program for a certain game
(TinyMUD by name; email me if you're curious enough).

Now, the actual AI part of it will be easy.  (Yeah, right.)  My
problem is accessing the telnet session.

How do I go about connecting to a specific port on another computer
through Lisp and have its I/O be used by a Lisp program, and, once
I have that data, how can I do something useful with it?

Here's an example.  Say that I first need to connect to port 4321 of
the machine with address 128.129.130.131.  Ordinarily I'd issue a
telnet command from the command line, but I'd like the same thing done
entirely by my program.

Then, after I connect, I read strings of input, and send back strings o
output in response.  For example, I might receive:

	The quick brown fox jumped over the lazy dog.

Ideally I'd like to be able to manipulate that sentence as a list of
words -- or, more interestingly, as a list of lists of letters.  How
do I process the input?  Similarly, how do I take the lists
manipulated by my program and turn them into strings of words?

Any and all help is appreciated.

     << Brian >>
-- 
| Brian S. Kendig      \ Macintosh |   Engineering,   | bskendig             |
| Computer Engineering |\ Thought  |  USS Enterprise  | @phoenix.Princeton.EDU
| Princeton University |_\ Police  | -= NCC-1701-D =- | @PUCC.BITNET         |
... s l o w l y,  s l o w l y,  w i t h  t h e  v e l o c i t y  o f  l o v e.

andy@Gang-of-Four.Stanford.EDU (Andy Freeman) (05/29/90)

In article <16796@phoenix.Princeton.EDU> bskendig@phoenix.Princeton.EDU (Brian Kendig) writes:
>Here's an example.  Say that I first need to connect to port 4321 of
>the machine with address 128.129.130.131.  Ordinarily I'd issue a
>telnet command from the command line, but I'd like the same thing done
>entirely by my program.

A number of lisp implementations, such as Lucid's Common Lisp, provide
facilities for running other processes and communicating with them
as if they were sequential files.

One useful process to run is a telnet process.  Depending on the
program at the other end, strings or s-expressions may be the
appropriate language.  (Personally, I've always had a lisp process on
the other end, so I passed s-expressions back and forth and so that I
could parse them with read.)  It isn't too difficult to figure out
where and when to flush the relevant buffers.

-andy
--
UUCP:    {arpa gateways, sun, decwrl, uunet, rutgers}!neon.stanford.edu!andy
ARPA:    andy@neon.stanford.edu
BELLNET: (415) 723-3088