use threads; use IO::Socket::INET; my $so = new IO::Socket::INET( PeerAddr => '127.0.0.1', PeerPort => 1300, Proto => 'tcp', Reuse => 1, ); die "Socket Error: $!\n" unless $so; my $thread = threads->create("start_thread"); my $thread1 = threads->create("start_thread1"); sub start_thread { while($so->recv($txt,128)){print "server : $txt";} } sub start_thread1 { while(my $msg = ){print $so "$msg"; } } $thread->join(); $thread1->join(); --------end of code----------- #### while($so->recv($txt,128)){print "server : $txt";}