Using TCP/IP

Donn Cave donn at u.washington.edu
Thu Oct 2 16:20:27 EDT 2003


In article <pan.2003.10.02.19.28.44.484000 at hotmail.com>,
 jblazi <jblazi at hotmail.com> wrote:

> So I shall do this. When I call ipconfig, I see two ip adresses:
> 
> 
> Ethernetadapter LAN-Verbindung:
> 
>         Verbindungsspezifisches DNS-Suffix:
>         IP-Adresse (Autokonfig.). . . . . : xxx.xxx.xxx.xxx
>         Subnetzmaske. . . . . . . . . . . : xxx.xxx.0.0
>         Standardgateway . . . . . . . . . :
> 
> PPP-Adapter XXXXXX:
> 
>         Verbindungsspezifisches DNS-Suffix:
>         IP-Adresse. . . . . . . . . . . . : xxx.xxx.xxx.xxx
>         Subnetzmaske. . . . . . . . . . . : 255.255.255.255
>         Standardgateway . . . . . . . . . : xxx.xxx.xxx.xxx
> 
> Python returns the first ip number but I should need the second one. (I
> replaced  the digits by 'x'.

I imagine that more generally you will need the address associated
with the network you're using.  One fairly simple way to arrive
at this is to connect to some well known service on that network,
and then get the bound connection's IP with getsockname().

   Donn Cave, donn at drizzle.com




More information about the Python-list mailing list