It is impossible to process a data segment if the data in it does not end with the characters 0x0A 0x0D
The server looks like this:
$server = IO::Socket::INET->new(LocalPort => 7777, TYPE => SOCK_STREAM, Reuse => 1, Listen => SOMAXCONN, KeepAlive => 1, Timeout => 10) or die "Couldn't be a tcp server on port $server_port: $@\n"; while($client = $server->accept()) { defined(my $child_pid = fork()) or die "Can't fork new child $!"; if ($child_pid == 0) { close( $server ); } $client->autoflush( 1 ); while(my $buffer = <$client>) { print unpack("H*", $buffer); } } For clarity, printed hexadecimal presentation of the data segment. Printing of received data is triggered only if the data segment is terminated with the characters 0x0A 0x0D, or if the buffer is full, or if the client has disconnected.
In addition, you need to be able to print all accepted segments, even without 0A 0D at the end.