How to determine own IP

Donn Cave donn at oz.net
Mon Feb 19 01:25:53 EST 2001


Quoth Michael Bauer <Mike_B at T-Online.de>:
...
| If a host has more than one network adapter, how do i know which IP should 
| i put inside  the PONG package? 
| Specifically, when dealing with dial-up users who are also connected to a 
| LAN, gethostbyname(gethostname()) always returns their internal adress.

If you have a connected socket s, s.getsockname() will return the
IP address and port number of the local endpoint.

	Donn Cave, donn at oz.net



More information about the Python-list mailing list