in reply to Re^2: IO::Socket Listen
in thread IO::Socket Listen
It could be that you need to send perhaps 128 bytes to it instead of a buffer ending in CRLF? Note: that CRLF is the network line ending, not just <LF>, so that part is right as far as it goes...However it could be that this thing is waiting for more bytes from you... Maybe..Send minimum 128 bytes? Read their spec..
Usually the smallest packet that will be sent is 128 bytes. Sometimes a 256 byte message will take a couple of packets even on the local machine.
Try just printing whatever the server returns to you on the first sysread() attempt. That will give you a clue as to what it is doing. If all you are expecting is less than 128 bytes, then you are probably done!
FYI, A Perl client read routine to get a 512 byte fixed packet might look like this:
my $buf = readn ($socket, 512);
Update: Perl will work with line oriented packets GREAT! But if that is not what this thing is sending back, then this is for naught. print the results of the first sysread() and see where that leads.sub readn { my ($socket, $bytes ) = @_; my $offset = 0; my $buf = ""; while ($offset < $bytes) { my $nread; my $nleft = $bytes-$offset; $nread = sysread($socket,$buf,$nleft,$offset); kill 'USR1',$$ unless (defined $nread); ## undef is like -1 uni +x return last if ($nread ==0); ## EOF $offset += $nread; } # print "length of received buff=",length $buf,"\n"; # print $buf; return $buf; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: IO::Socket Listen
by Secalles (Initiate) on Dec 06, 2011 at 13:51 UTC | |
by Eliya (Vicar) on Dec 06, 2011 at 14:26 UTC | |
by Secalles (Initiate) on Dec 06, 2011 at 14:45 UTC | |
by Eliya (Vicar) on Dec 06, 2011 at 15:03 UTC | |
by Secalles (Initiate) on Dec 07, 2011 at 11:29 UTC | |
|