Thread: IP adresses
View Single Post
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: IP adresses

 
0
  #5
Nov 7th, 2005
Originally Posted by vegaseat
It might depend on what OS you are using, but here is one way ...
[php]# socket.getaddrinfo returns a list of tuples
# tuple[4][0] of each list element is the IP address

import socket

addrs = socket.getaddrinfo(socket.gethostname(), None)
for addr in addrs:
print addr[4][0]
[/php]
I just tested your code, that just gets the internal ip, would he need his external IP?
In a perfect world exceptions would not be needed.
Reply With Quote