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.
In reply to Socket connection refused problem by nikhilx64
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |