use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => '7070', Proto=>'tcp', Listen=>1, Reuse=>1, ); my $new_sock = $sock->accept(); $i=0; while(1){ print $new_sock "HIII CALLER!\n"; print $new_sock "stop reading ,caller!\n"; while(<$new_sock>){ print $_; if($_ == "stop reading ,receiver!\n"){ last; }; } } close($sock);