[Tutor] socket question

Alan G alan.gauld at freenet.co.uk
Tue Sep 13 13:22:22 CEST 2005

> When I receive a 4-bytes integer using socket.recv, it is stored in 
> a
> string. How to convert this string to a integer?

Look at the struct module.
Its unpack method takes a format string which defines how the data
should be interpreted.

Have a look at the section at the end of my  file handling topic for
some info and examples of usage:

Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list