ip address?
maximilianscherr
MaximilianScherr at T-Online.de
Sat Jan 26 06:27:22 EST 2002
thanks, haven't tried it yet, but perhaps will work, and i only have
two ips i think one for the lan and one for the net, so i just tell
it if not "192.168.0.10" right?
--- In python-list at y..., "Joshua Muskovitz" <joshm at t...> wrote:
> > thanks, but i think this also won't tell me my internet address,
at
> > least when i tried it just got my lan ip which is just 192.0.0.10
all
> > the time.
>
> In a DOS window, run winipcfg (win98) or ipconfig /all (win2k) and
see what
> it tells you. If you have *multiple* IP addresses (one for your
dial-up and
> one for your lan, maybe?), then socket.gethostname() will return
*one* of
> them, but it could be either of them. This is one of the nastier
parts of
> TCP, and has nothing to do with Python.
>
> At the python command line, try this:
>
> import socket
> hostname = socket.gethostname()
> addresses = socket.getaddrinfo(hostname, None)
> ips = [x[4][0] for x in addresses]
>
> This should give you all of the IP addresses for your machine.
It's your
> problem to figure out which one is for your dialup provider. Don't
assume
> it'll always be the same index into this list.
>
> --
> # Joshua Muskovitz
> # joshm at t...
> def lyyrs(sig): return '-'.join(sig.split()+["ly y'rs"])
> lyyrs('Hire me! I need the work!')
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 80,000 Newsgroups - 16 Different Servers! =-----
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list