newbie sending hex values over UDP socket
Bill Seitz
fluxent at yahoo.com
Fri Sep 10 12:43:00 EDT 2004
Jason Lai <jmlai at uci.edu> wrote in message news:<chr22o$7ra$1 at news.service.uci.edu>...
> Bill Seitz wrote:
> > I'm working with an outside "partner" to whom I want to send messages
> > (I want my app to send messages to his server/receiver). He requests
> > that I use UDP and an "industry standard" for formatting the data
> > itself.
> >
> > That format is basically a bunch of hex bytes.
> >
> > So instead of sending 3 alphanum chars
> > ri0
> >
> > I have to send 3 bytes which he explains as being
> > 72 69 30
> >
>
> Well, since he says you're sending three bytes, I assume it's the second
> format. But the second format happens to be the same as the original.
>
> Observe:
>
> >>> "\x72\x69\x30" == 'ri0'
> True
>
> Bytes are bytes, regardless of whether you write them as characters,
> binary, decimals, or hexidecimals.
>
> - Jason Lai
Are you saying I can just do something as simple as
sock.send('ri0')
?
(This interface is typically used over a modem connection between 2
embedded/hardware devices, if that provides a clue/context. So it's
entirely possible that I've thought the situation was more complicated
than it really is because the other guy is used to dealing with these
low-level devices...)
More information about the Python-list
mailing list