socket send query
ptmcg at users.sourceforge.net
Wed Feb 18 21:19:28 CET 2004
"connections cardiff" <sb at networkdata.co.uk> wrote in message
news:69fe7511.0402181012.3187517f at posting.google.com...
> hi all,
> i want to mimic what another software program sends to a server.
> if i look with a sniffer i can see the hex data that is being sent by
> the real software program.
> how can i send such data?
> if i send the hex data values with a socket send then python assumes i
> am trying to send a string of ascii characters and when i look at what
> was sent in the sniffer i see the data i sent has been coverted into
> their corresponding hex values. I want python to leave it alone and
> send it.
> i guess if my hex values had acsii equivalents i could send them and
> they would be converted to the data i want but i dont think all my hex
> data has acsii equivalents..
> is there another way i should be doing this?
> PS. IN CASE YOU DIDNT NOTICE I AM A NEWBIE!
> many thanks
The struct module may be of help to you. Write up how your data packet
would look as a C struct, create the corresponding struct format string (see
the struct docs), then use the pack() and unpack() methods to convert your
Python data to and from the raw binary data form.
More information about the Python-list