newbie sending hex values over UDP socket
me at privacy.net
Fri Sep 10 04:06:32 CEST 2004
On 9 Sep 2004 18:44:16 -0700,
fluxent at yahoo.com (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
> That format is basically a bunch of hex bytes.
> So instead of sending 3 alphanum chars
> I have to send 3 bytes which he explains as being
> 72 69 30
> Now, what the heck should I really be sending? I know he's giving just
> a simplified representation.
Looks like your partner's "industry standard" is plain old ASCII:
>>> [ hex( ord( x )) for x in 'ri0' ]
['0x72', '0x69', '0x30']
Yeah, that's what I'd guess. Did you type that byte string into an
> If I'm aiming for the 2nd format, how do I best generate it? If I'm
> going the other direction, it seems like
> works OK
If your data is in a byte string, then you're all set; just stuff the
byte string in question down the socket. (I'm assuming that (a) there's
more to the protocol, or (b) the other end knows how much data to accept
based on the actual data received).
Never play leapfrog with a unicorn.
More information about the Python-list