[Tutor] Will someone please tell me how to read this?

ZIYAD A. M. AL-BATLY zamb at saudi.net.sa
Mon Aug 22 21:27:09 CEST 2005


On Mon, 2005-08-22 at 13:18 -0500, Lane, Frank L wrote:
> Hi List,
> 
>  
> 
> I cut and pasted a dump from recvfrom below.  I can’t read it and
> don’t where to look in the documentation to figure out how to read
> this.
> 
>  
> 
> Is there a name for this type of number?  I’m assuming the \x means
> it’s hex,
Correct.

> but then you have things like \x00h, and \x007p^.
Coincidence!  '\x00h' means:  there's a byte with a value 0 followed by
a byte with a value 104.  Since 104 is 'h' in ASCII table and can be
represented in a human form, Python displayed it as 'h'.  On the other
hand, 0 doesn't have a human form to represent it, and thus, Python
displays it as '\x00'.

Likewise with the '\x00p^'.

> 
>  
> 
> Any help here is greatly appreciated.
> 
>  
> 
> Code snippet:
> 
>  
> 
> text = server.recvfrom(1024)
> 
> print repr(text)
> 
>  
> 
> '\x05\x01\x03\x02\x05\xaf\xce\x04\x00h\x00\x00\x00\x01\x007\x00\x01
> \x00\x01\x007p^\x00\x00\x00\x00\x00\x00\x00\x01\x007\x00\x04\x00\x00
> \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00AN\x94\n\x923\xcaXA$s\xdc(\x1e
> \xcf\xbaAR\xb6\xc9\x1c\x1e%#\x02\x02\x00\xe1\x00\x00\x00\x00\x00\x00
> \x03\xe8\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
> \x00\x01\x00\x00\x00'
> 
This is binary.  In other words, it's no use for human as is.

You need to know how to interpret this sequence of bytes to something
useful.  It might be compressed or need to be translated.

Your solution is must likely in the other end of the connection.
Consult the SERVER and see what it really sends to you!

>  
> 
> Thanks,
> 
> Frank
>
Ziyad.



More information about the Tutor mailing list