Further more when I try the folowing code on another machine I get a 'Connection refused' error:#!/usr/bin/perl -w use strict; use IO::Socket; my $new_sock; my $buf; my $sock = new IO::Socket::INET (LocalHost => 'foo', localPort => 1880, Proto => 'tcp', Listen => 5, Reuse => 1 ); die "Unable to create socket: $!" unless $sock; print "Waiting for message...\n"; while ($new_sock = $sock->accept()) { print $buf while (defined ($buf = <$new_sock>)) } close ($sock);
These examples come from Advanced Perl, So I suspect they are correct.#!/usr/bin/perl -w use strict; use IO::Socket; my $sock = new IO::Socket::INET (PeerAddr => 'foo', PeerPort => 1880, Proto => 'tcp' ); die "Could not create socket: $!\n" unless $sock; while (1) { print "Enter message: "; chomp (my $msg = <STDIN>); print "Sending $msg\n"; print $sock "$msg\n"; $sock->flush; } close ($sock)
Update:
The server code is running on a windows nt4 machine while the client is an HPUX 11.x box
UPDATE:
I've got it working!
I noticed that while setting up the $sock object I did
The localHost shouldbe LocalHost.my $sock = new IO::Socket::INET (LocalHost => 'sgilbertdt', localPort => 1200, Proto => 'tcp', Listen => 5, Reuse => 1 );
As soon as I made the change and ran the script again, it showed up in netstat and I was able to pass the message from my Unix client.
Spelling Counts
Thanks Everyone
TIA
Sweetblood
In reply to Trouble with sockets by sweetblood
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |