How can Client get "Client IP" ?

Discussion in 'Python' started by polarpolar, Jul 22, 2004.

  1. polarpolar

    polarpolar Guest

    Hi, All :

    I wrote a simple server in Python,
    and I can get the client IP by following script:

    s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
    s.bind( (HOST, PORT) )
    s.listen(1)
    conn, addr = s.accept()
    clientIP = addr
    s.close()

    That's wonderful.
    However, I hope that my client can get his own IP "by himself".
    ( Not by server :Q )
    So what can I do ?
    Is there a CONST I can use ?

    Thanks.
     
    polarpolar, Jul 22, 2004
    #1
    1. Advertising

  2. polarpolar

    Jeff Epler Guest

    For a socket object s, s.getsockname() "Return the socket's own address.
    This is useful to find out the port number of an IPv4/v6 socket, for
    instance. (The format of the address returned depends on the address
    family -- see above.)"

    Jeff

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.1 (GNU/Linux)

    iD8DBQFA/8SbJd01MZaTXX0RAuwEAJ9dZx9n1KiIOfjMdkVxvJfbRztL+QCeIkmB
    BNtLedI1YdSynUdTwsAp+0s=
    =YT72
    -----END PGP SIGNATURE-----
     
    Jeff Epler, Jul 22, 2004
    #2
    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. DirkDiggler

    how can I get client IP addresses?

    DirkDiggler, Feb 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    388
    Eric Lawrence [MSFT]
    Feb 20, 2004
  2. Sammy
    Replies:
    12
    Views:
    1,225
    Richard Tobin
    May 6, 2005
  3. John Dalberg
    Replies:
    4
    Views:
    794
  4. Guy
    Replies:
    2
    Views:
    194
    Dr John Stockton
    Dec 5, 2003
  5. TheBelangerFamily
    Replies:
    0
    Views:
    125
    TheBelangerFamily
    Mar 21, 2006
Loading...

Share This Page