Sockets: Receiving C Struct

Johnny Venter Johnny.Venter at
Fri Aug 5 14:15:53 CEST 2011

New to python and would like to test network/sockets with it.

I am having a problem where I have setup the following:

import socket, sys, struct

HOST = ''
PORT = 153
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

data = struct.unpack('!I',s.recv(4))[0]


print data

What I would like to do is take the input from the server, and store it in an array.  The type of data is int.

Can someone help?

Thanks, Johnny

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 841 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Python-list mailing list