Fwd: Sockets: Receiving C Struct

Discussion in 'Python' started by Johnny Venter, Aug 5, 2011.

  1. 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 <>
    > Date: August 5, 2011 8:15:53 AM EDT
    > To:
    > 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-----
     
    Johnny Venter, Aug 5, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RA Scheltema
    Replies:
    3
    Views:
    414
    RA Scheltema
    Jan 6, 2004
  2. Davide Carboni
    Replies:
    0
    Views:
    376
    Davide Carboni
    Dec 18, 2003
  3. Chris Fogelklou
    Replies:
    36
    Views:
    1,431
    Chris Fogelklou
    Apr 20, 2004
  4. Johnny Venter

    Sockets: Receiving C Struct

    Johnny Venter, Aug 5, 2011, in forum: Python
    Replies:
    0
    Views:
    164
    Johnny Venter
    Aug 5, 2011
  5. Bigus

    Sockets: receiving data

    Bigus, May 21, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    175
    Bigus
    May 22, 2004
Loading...

Share This Page