|go ahead... be a heretic|
Sockets! Controlling Receiver partby ali_kerem (Acolyte)
|on Jun 23, 2013 at 12:41 UTC||Need Help??|
ali_kerem has asked for the
wisdom of the Perl Monks concerning the following question:
I have a question about socket programming which is about controlling the data through Socket->Recv.
I have a script that sends and receives commands to system RCV from system SND according a protocol which uses hexadecimal codes. I send a command to RCV and according to its meaning it does its job and reply to SND with one or more commands, then it continues until SND sends deactivate command. Each message has a head and tail obviously. So when I receive a message I convert into hex to understand it, like;
The problem is, sometimes SND sends a long command and RCV replies many long commands and it doesnt fit in my defined length. So lets say it gets 10 messages with head and tail but it loses 11th tail and the next time it receives a message which continues 11th message, meaning no head but body and tail...
When I increase data length, its not 11th message but 21th message this time. So there is no limitations, sometimes I see three messages without proper head.
So due to this problem I want to control receiver part with head and tail packets, but I don't know how. Because I convert it to meaningful hex part after I receive it, not while receiving it...
Pleease guide me or at least a hint, thanks.