I think you need to read the spec on the I/F to this server. You are sending <CR><LF> at the end of your packet, but many of these things work with fixed length packets instead of line oriented packets.

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);

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; }
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.
***Also perhaps try a flush() on your end! Normal socket IO is buffered. $socket->flush().

In reply to Re^3: IO::Socket Listen by Marshall
in thread IO::Socket Listen by Secalles

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.