Hey all,
I'm trying to learn a bit about Perl sockets. I got these simple
client/server scripts from http://www.perlfect.com/articles/sockets.shtml
and I can't even get them to work. When I run the client against the server
I get no output at the server. The "Socket defined" line does get printed so
I assume that means that the socket is connected. I get
"IO::Socket::INET=GLOB(0xf6420)" as the file handle from the client. I have
no idea if that is correct. Is there something missing, how does $_ get
assigned the input from $new_sock? Thanks.
Server:
#!/usr/bin/perl
use IO::Socket;
my $sock = new IO::Socket::INET (
LocalHost => 'IP_GOES_HERE', (<-- yes this
is set properly)
LocalPort => '60000',
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create socket: $!\n" unless $sock;
my $new_sock = $sock->accept();
while(defined(<$new_sock>)) {
print "Socket defined\n";
print $_;
}
close($sock);
Client:
#!/usr/bin/perl
use IO::Socket;
my $sock = new IO::Socket::INET (
PeerAddr => 'IP_GOES_HERE',
PeerPort => '60000',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print "$sock\n";
print $sock "test\n";
close($sock);
Dave Sorrells
ciber
Office: (585) 231-2071
Cell: (585) 755-9015
Email: [EMAIL PROTECTED]
Text Messaging: [EMAIL PROTECTED]
AIM: Dave Ciber
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]