HumanProgrammer has asked for the wisdom of the Perl Monks concerning the following question:
Hello! Here is my perl script. I tried to communicate
on the same port, but it wasn't worked. I can send message
to a server, but I cannot get any response. The response is
sent out from the server in the 30000 port - I tested the
server with a C++ client and the same scenario worked fine.
Maybe this line is wrong: my $new_sock = $sock->accept(); What other lib should I use? How could I fix it?#! /usr/bin/perl use IO::Socket::INET; my $sock = new IO::Socket::INET ( PeerAddr => '127.0.0.1', PeerPort => '30000', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; print $sock "Hello there!\n"; my $new_sock = $sock->accept(); while(defined(<$sockin>)) { print "Arrived?\n"; print $_; } print "Stopped! \n"; close($sock);
Br, HP
Edit by tye, remove PRE tag, preserve formatting
Back to
Seekers of Perl Wisdom