Fwd: Sockets: Receiving C Struct

J

Johnny Venter

I was not sure if this message was sent before my membership was accepted.

Please disregard if it's a duplicate.

Thanks

Begin forwarded message:
From: Johnny Venter <[email protected]>
Date: August 5, 2011 8:15:53 AM EDT
To: (e-mail address removed)
Subject: Sockets: Receiving C Struct

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 = '1.1.1.1'
PORT = 153
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

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

s.close()

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


-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)

iQIcBAEBAgAGBQJOO+qaAAoJEBRo55dgl7RwZe8P/3L+gkdcxg+BCl2fXflFf1pj
S25kG7PGoW7mINzt6g2I9jbzxHQ/IEf1IdV7D7NNjowjQGN60NI7d+3kdfuArW43
WNgd5f6JzZiz52TK71oYjjzlME8r22EBek1IKNoLqowEJvsC4BXbyKgZrS44rJP2
lt8hwNzxQVkhKSYJTmHx/qkKeeErLgofiqOBUlnqKXk0UKtyqUs5+cyVo4ysD6NF
TxWmfieCc58JVhVevK0YEnJyLxZEU8br6dJdnnRcZZGBJ5dItrx2uEnJumUPpuVG
Ymnvf52v8oNjNlIgtpspXA88Elfi9x3f0Fq5ynvQfI8tI3jOofbX2q9EyWb8tcrM
y6RRwxIBoUhHKMZ/oaocrqBZrg+0LPb/OzQLTcVApV9QLLKMXPugg5aFenYnriZD
bZLXuL+L/0DF4F8wRCA+H2AcNg0BdwvXqmPP/C6P8nrAJsx3EGl3Q5F7rsZVrsfW
g+2msW/mB9a81LLYpN9Kf2TXUn9quVk2NhPvRUSCylkfiL/sqDc5nvRa+94TKCwv
VEEUm48fnVvJ6JzAFwi1AT6WpSuUngZS6h2fOyIqToDGTMSjueNeL0xqmR5YY0hs
3wc5DO0b07OdRalICRwIh3UuQjNMvVi28slxIalt4iqboLIyEUQCeEPczZrl16L/
X/LiJhfafOVe5y8rWj9l
=DOVp
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top