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

[MacPerl] Character-by-character client/server with echo control?



Hi guys,

    I am despairing of finding an answer to this one so I thought I
would ask the gurus on this list. It isn't terribly Mac-specific,
but there seem to be some Really Knowledgeable Guys out there, so
I'm hoping at least one of them can help me out. Thanks.

    I'm trying to write a client-server front-end for some database
manipulations in Perl. The server listens on a specific TCP/IP port,
fork()s children to handle connections, bla bla bla. I ripped off the
source from the Camel book.

    Two problems:

    1) I gave up trying to write a client in Perl that would read from
the socket character-by-character. Perl seems bent on reading at least
a line at a time. I finally gave up and am using a Telnet client to
talk to my server, only this means I have to do some funky control
character filtering. Is there a better way? Before you ask, *yes*, I
really do want to do char-by-char reading and writing; I want to be
able to send a prompt line "login> " and have the client print it so
the user can input on the same line. Is this really so hard to do?

    The Camel book says that $/ is the input record seperator. I was
all ready to set this to null, but that is documented as meaning "no
record separator is matched, and <FILEHANDLE> will read everything to
the end of the current file". This is bad.

    2) I know I can do 'system "stty -echo"' on UNIX boxes to turn off
echoing on the terminal. How can I control this on a socket? If I had
my own client, I would send it a special character sequence to tell it
to turn off echoing, but see 1). If 1) is impossible, does someone
have code for sending the Telnet disable-echo option command?

    I want to do 2) because I prompt for a username and password first
thing so I can log who uses the server. I would rather the password
not appear on the console, but that's what's happening now.

    Any help appreciated. I'm sick of staring at RFCs and Perl pages.

    Mark

 -------------------------------------------------------------------------
| Mark A. Aiken                      Macintosh wizard and shareware author|
| Undergrad, McGill U, Mtl, CANADA   marka@kagi.com / marka@ee.mcgill.ca  |
| WWW site of Macintosh shareware at http://www.kagi.com/authors/marka    |
| General WWW home page at           http://www.ee.mcgill.ca/~marka       |
 -------------------------------------------------------------------------