use IO::Socket; $sock =0; while(!$sock){ $sock = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => '7070', Proto => 'tcp', ); } die "Could not create socket: $!\n" unless $sock; while(1){ print $sock "HIIII RECEIVER!\n"; print $sock "stop reading ,receiver!\n"; while(<$sock>){ print $_; if($_ == "stop reading ,caller!\n"){ last; }; } }; close($sock);