Perl gurus,
Thank you to all of the people who helped me out. I'm right up to the
end and think I know what I need to do now in order to send the binary
data stream across the socket.
I am using "pack" to send 10 bytes of data as a stream, but the
problem is that pack isn't working as I'm trying to make it work.
Can anyone help that has used it before?
Here is how I am using pack in my code:
$bytestring = pack("H20", 150, 223, 72, 0, 131, 4, 0, 0, 0, 1);
Note that my program functions as a tcp client; It is attempting to
send $bytestring across to a TCP server, but
the $bytestring is not being formatted properly before it is sent. Pack is properly
decoding this into 10 bytes of data (the quantity of bytes are correct
with "H20", but the representations for the byte values are all wrong.
My packet sniffer says I am sending out the following:
00 0A 15 00 00 00 00 00 00 00 00 00
(the first "00" byte is a pad, the "0A" tells how many bytes are sent,
but all of the bytes afterwards are wrong)
The string should look like this when it is sent:
00 0A 96 DF 48 00 83 04 00 00 00 01
My send routine handles the number of bytes that are sent; my problem
is really in getting the decimal characters to "pack" properly into a
binary string of data. Something is not quite correct in what I am
doing.
Can anyone help? Is there a better perl forum to direct my question?
Thanks so much!
-Jason
Jason Ostrom> Hello,
Jason Ostrom> I was wondering if any of you guys could help me out with some insight
Jason Ostrom> on building a data structure for sending and receiving binary data.
Jason Ostrom> Here is what I am doing:
Jason Ostrom> 1. building a tcp client to query a server with data
Jason Ostrom> 2. the client sends the binary data stream, and then receives binary
Jason Ostrom> data stream from server, and closes the socket
Jason Ostrom> 3. I would like to be able to build a structure where I can modify
Jason Ostrom> certain bytes (whether decimal, hex, or binary) before sending the
Jason Ostrom> stream, such as to create a "message", and then sending the message to
the server.
Jason Ostrom> 4. When the message is received, I would like to be able to read it
Jason Ostrom> into an ordered structure so that I can retrieve certain bits after I
Jason Ostrom> have decoded the stream into decimal or hex ASCII representations.
Jason Ostrom> For example, my packet sniffer is showing the following:
Jason Ostrom> 0000: 000a c844 0000 f00a 0401 0008 0009 c844 ...D...........D
Jason Ostrom> 0010: 0000 f00b 0000 0000 07c8 4080 00dc a000 ..........@.....
Jason Ostrom> I need to read each one of these bytes in a de-limited way.
Jason Ostrom> Has anyone done this before or can give me any kind of insight? Is
Jason Ostrom> there another list that would be better for this? I would GREATLY
Jason Ostrom> appreciate any and all insight.
Jason Ostrom> Thanks,
Jason Ostrom> Jason O.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]