perlquestion
HumanProgrammer
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.
<code>
#! /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);
</code>
Maybe this line is wrong: my $new_sock = $sock->accept(); What other lib should I use? How could I fix it?
<p>
Br, HP
<p><small>Edit by [tye], remove PRE tag, preserve formatting</small></p>