in reply to Telnet, XML API, and I/O Buffering

Hi,

If you have the book "Advanced Perl programming" (the one by Sriram Srinivasan) you could use the Msg toolkit explained there (chapter 13).

Its also downloadable on CPAN: http://search.cpan.org/~sriram/examples/

It provides a wrapper around sysread which makes sure the complete message is received.

Replies are listed 'Best First'.
Re^2: Telnet, XML API, and I/O Buffering
by BluePerlDev (Novice) on Jul 29, 2010 at 19:48 UTC

    I do have that book, and have tried to use the Msg module, but have met with slightly different results now... details below:

    First, the new code I am using:

    use Msg; my $conn = Msg->connect($WYSHOST, $WYSPORT); die "Couldn't connect to $WYSHOST on $WYSPORT" unless $conn; $conn->send_now($NODEREC); $conn->send_now("\n"); ($res, $err) = $conn->rcv_now(); print Dumper($res), "\n"; print Dumper($err), "\n";
    and the results end up with $res and $err both being '':
    $VAR1 = ''; $VAR1 = '';

    Should I view this as an error in the part f sending over the XML record that requests the data from the application? Or as some strange buffering issue on hte receiving host's side?

    again, many thanks in advance for all the help so far.

      Hi,

      Did you implement the Msg toolkit on the sending side as well or only on the receiving side ?

      It has to be implemented on both sides because it enforces a kind of protocol. For example, one of the protocol requirements is that the server has to mark the beginning of each message with a four byte message length otherwise the rcv_now sub (which calls _rcv) doesn't work correctly.

      Hope this helps.