How can Client get "Client IP" ?

P

polarpolar

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.
 
J

Jeff Epler

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-----
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top