I have the following simple socket code based on page 194 of Advanced Perl
Programming. But I can not connect to this server. I get 'Connection
refused!'. Am I doing something wrong here or do I need to do something to
open up the port? I tried to test this using 'telnet goreliance.com 3333'.
I get the same type of error from a client script too.
TIA.
Message I get:
Connecting To goreliance.com...Could not open a connection to host on port
3333
: Connect failed
Code:
use IO::Socket;
$SIG{CHLD} = sub {wait ()};
$main_sock = new IO::Socket::INET (
LocalHost =>'208.179.25.28',
Localport => 3333,
Listen => 3,
Proto => 'tcp',
Reuse => 1,
);
die "$0 Socket could not be created.\n$!\n" unless ($main_sock);
while ($new_sock = $main_sock->accept()) {
$pid = fork ();
die "Cannot fork: $!" unless defined($pid);
print "Connecting to a new client \n";
if ($pid == 0) { # child process
while (<$new_sock>) {
print ;
}
exit (0);
}
}
close ($main_sock);
1;
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm