This worked great.  I had to tweak it a *little* bit because I'm
after a slightly different thing, but I am now happily printing data from
the client to STDOUT (and understanding how that works, too).  
        BTW, this TCP/IP server is a test tool for some brokerage software.
A few more lines of code and I'll be impersonating the New York Stock
Exchange!  
        -Chris  

-----Original Message-----
From: Gupta, Sharad [mailto:[EMAIL PROTECTED]
Sent: Monday, June 23, 2003 4:41 PM
To: McMahon, Christopher x66156; [EMAIL PROTECTED]
Subject: RE: basic question: handling input to TCP/IP server


Something like this worked for me in the past:

use strict;
use IO::Socket::INET;
my $sock = IO::Socket::INET(....);

while(1) {
        my $output;
        my $n = sysread($sock,$output,1000);
        last if(!defined($n));
        print STDOUT $output;
}

And using syswrite() for writing.

perldoc -f sysread
perldoc -f syswrite

-Sharad

-----Original Message-----
From: McMahon, Christopher x66156 [mailto:[EMAIL PROTECTED]
Sent: Monday, June 23, 2003 3:06 PM
To: [EMAIL PROTECTED]
Subject: basic question: handling input to TCP/IP server


Hello all...
    I've implemented the TCP/IP server at the top of p.441 of The Camel (3rd
edition) Chapter 16, and it's working fine.  That is, it opens the port I
tell it to, and other processes connect to it and happily send it stuff.
(This is using IO::Socket::INET).  
    But now I'm a little confused about how to handle I/O over the TCP/IP
connection.  The first thing I'd like to do is to print incoming data to
STDOUT.  It seems that I have to manipulate the "accept()" statement, and I
probably have to use the angle operators, but I'm struggling to truly
understand what's going on here in order to get the syntax correct.  (I
figure if I can get a handle on manipulating the input, output will be
easy.)   
    I'm continuing to hack at this, but any pointers to (simple!) TCP/IP
server behavior to speed me on my way would be welcome.  
    Thanks, 
-Chris   

_
This message and any attachments are intended only for the use of the
addressee and
may contain information that is privileged and confidential. If the reader
of the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this
communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.

Reply via email to