nikhilx64 has asked for the wisdom of the Perl Monks concerning the following question:
I have two PERL programs that I am attempting to connect via sockets. The code below works fine when I attempt to connect to the socket on the same machine i.e. localhost.
Program: socketopen
use warnings; use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => '12345', Proto => 'tcp', Listen => 1, ReuseAddr => 1, ); die "Could not create socket : $!\n" unless $sock; print "Socket created: $sock\n"; my $newsock = $sock->accept(); while (<$newsock>) { print $_; } close($sock);
Program: socketconnect
As soon as move one program to another machine I get: "Could not create socket : Connection refused"use warnings; use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => '192.168.x.xx', PeerPort => '12345', Proto => 'tcp', ); die "Could not create socket : $!\n" unless $sock; print $sock "Hello there!\n"; close($sock);
Both machines are running Ubuntu. I know that the port is in a listening state from the output of netstat -tlp. And the Ubuntu firewall is inactive on both machines.
Any help and nudges in the right direction will be greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket connection refused problem
by ikegami (Patriarch) on Feb 01, 2011 at 07:04 UTC | |
|
Re: Socket connection refused problem
by andal (Hermit) on Feb 01, 2011 at 08:38 UTC | |
|
Re: Socket connection refused problem
by nikhilx64 (Initiate) on Feb 01, 2011 at 15:21 UTC |