newbie sending hex values over UDP socket

Bill Seitz fluxent at yahoo.com
Thu Sep 16 09:47:50 EDT 2004


Peter Hansen <peter at engcorp.com> wrote in message news:<U7ydnYPTdJKtW9XcRVn-hQ at powergate.ca>...
> Bill Seitz wrote:
> 
> > Current stump in this area: taking current time (time.time()) and
> > delivering as 4-byte blob.
> > 
> >>>>t= int(time.time())
> >>>>format = 'l'
> >>>>struct.pack(format,t)
> > 
> > '\x10\xb7HA'
> 
> What's wrong with this one?  Note that it is a 4-byte
> blob, as requested.  You can always check that with
> len(s).  In this case, len('\x10\xb7HA') == 4.
> 
> -Peter

Weird, I guess I'm not used to reading that format - it sure looks
like 3 bytes to me. I guess I need to read up some more to get a
better grasp... and until then use len() instead of my eyes! :)



More information about the Python-list mailing list