Fwd: Sockets: Receiving C Struct
Johnny Venter
Johnny.Venter at zoho.com
Fri Aug 5 09:05:30 EDT 2011
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 <Johnny.Venter at zoho.com>
> Date: August 5, 2011 8:15:53 AM EDT
> To: python-list at python.org
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110805/9f674e7f/attachment-0001.html>
-------------- 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: <http://mail.python.org/pipermail/python-list/attachments/20110805/9f674e7f/attachment-0001.sig>
More information about the Python-list
mailing list