C:\>type io.pl use IO::Socket; $|++; my $sock = new IO::Socket::INET( LocalHost => 'localhost', LocalPort => 1234, Proto => 'tcp', Listen => SOMAXCONN, Reuse => 1 ) or die "no socket :$!"; while ($new_sock = $sock->accept()) { my ($buf, $char); while ( defined($char = $new_sock->getc) ) { print $char; $buf .= $char; do{process($buf); $buf = ''} if $buf =~ m/END$/; exit if $buf =~ m/QUIT/; } } sub process { print "\nProcessing: $_[0]\n" } C:\>io.pl testing using: telnet localhost 1234END Processing: testing using: telnet localhost 1234END send data as a streamEND Processing: send data as a streamEND buffer input yourself and process as requireedEND Processing: buffer input yourself and prosess as requireedEND Hope that helpsQUIT C:\>