true has asked for the wisdom of the Perl Monks concerning the following question:
One more piece of evidence is when i run this tool it gets to the read part and sits there. But if I reset my computer's ip address (changed wifi networks) the response string I was expecting through the socket listen suddenly appeared as the program dies. I am running this on a windows7 machine btw but eventually will end up in unix. Here's the code simplified for illustration.
use strict; use IO::Socket; my $server = "192.168.1.106"; my $sock = new IO::Socket::INET->new( PeerAddr => $server, PeerPort => 4998, Proto => 'tcp', Type => SOCK_STREAM, ); $sock or die "no socket for $_: $!"; $sock->autoflush(1); #Send a device command ending with return (slash r) print $sock "getdevices\r"; #here is where i am stuck... while (<$sock>) { print "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A Socket problem - successful write, failed read
by BrowserUk (Patriarch) on Jul 19, 2010 at 02:25 UTC | |
by true (Pilgrim) on Jul 19, 2010 at 02:36 UTC | |
|
Re: A Socket problem - successful write, failed read
by Anonymous Monk on Jul 19, 2010 at 02:16 UTC | |
by true (Pilgrim) on Jul 19, 2010 at 02:18 UTC | |
by Anonymous Monk on Jul 19, 2010 at 02:58 UTC |