I have this new IP2IR device which basically allows me to use my computer to control infrared devices in my home. It is from a company called global cache (in case anyone is interested). The documentation lacks a good 'hello world' but it does come with some test executables. I have been trying to control the device through perl. I have had luck with sending commands via sockets but i cannot read the response from the device. I know the device sends a response (they have a utility which shows me the output). I'm trying to fetch this output via perl. The code below works great until the read socket part. It doesn't return anything.
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";
}
Thanks for reading!
jtrue