Just use getc to get each input char as it arrives, buffer and process as required
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:\>
In reply to Re: Socket IO now new line
by tachyon-II
in thread Socket IO NO new line
by indigo1tx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |