I have found a simple script using IO::Socket to connect across two machines.
The article says that if I only want to use it on one machine then just change the PeerAddr attribute to make it so (as Jean Luc would say).
Anyway here's the code for the receiver;
This works fine and starts OK, waiting for input. Here's the calleruse IO::Socket; my $sock = new IO::Socket::INET ( LocalAddr => 'localhost', LocalPort => 10000, Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket\n" unless $sock; my $new_sock = $sock->accept(); while(defined(<$new_sock>)) { print $_; } close($sock);
use IO::Socket; my $sock = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => 10000, Proto => 'tcp', ); die "could not create socket\n" unless $sock; print $sock "Hello there\n"; close($sock);
So as soon as I start the caller script, the receiver script prints an error stating that $_ in the print statement was not initialised.
Or to be more precise;
Use of uninitialised value at ./receiver.pl line xx, <GEN1>, chnuk 1
Can someone please point me in the right direction to get this working? There must be something rather fundamental that both the author of the code and myself are not aware of.
Many thanks.
readey
In reply to Using IO::Socket by readey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |