Re: Getting externally-facing IP address?

2006-11-10 Thread Tim Williams
On 10/11/06, Michael B. Trausch [EMAIL PROTECTED] wrote:



  
  



Every programming example that I have seen thus far shows simple server code and how to bind to a socket--however, every example binds to the localhost address. What I am wondering is this: Is there a clean way to get the networked IP address of the machine the code is running on? For example, my laptop's IP address is 
192.168.0.101, and I want to bind a server to that address. Is there a clean way of doing so that will work, for example, when I move the code to my server (which obviously doesn't have the same IP address)?


Try using 0.0.0.0 as the IP address, or possibly giving IP address at all. HTH :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Getting externally-facing IP address?

2006-11-10 Thread Tim Williams
On 10/11/06, Tim Williams [EMAIL PROTECTED] wrote:


 On 10/11/06, Michael B. Trausch [EMAIL PROTECTED] wrote:
 
 
 
  Every programming example that I have seen thus far shows simple server
 code and how to bind to a socket--however, every example binds to the
 localhost address.  What I am wondering is this:  Is there a clean way to
 get the networked IP address of the machine the code is running on?  For
 example, my laptop's IP address is 192.168.0.101, and I want to bind a
 server to that address.  Is there a clean way of doing so that will work,
 for example, when I move the code to my server (which obviously doesn't have
 the same IP address)?
 
 

 Try  using 0.0.0.0  as the IP address,  or possibly giving IP address at
 all.

 HTH :)



Correction:

- or possibly giving *no* IP address at
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting externally-facing IP address?

2006-11-10 Thread Laszlo Nagy
Michael B. Trausch wrote:
 Hello,

 Every programming example that I have seen thus far shows simple 
 server code and how to bind to a socket--however, every example binds 
 to the localhost address.  What I am wondering is this:  Is there a 
 clean way to get the networked IP address of the machine the code is 
 running on?  For example, my laptop's IP address is 192.168.0.101, and 
 I want to bind a server to that address.  Is there a clean way of 
 doing so that will work, for example, when I move the code to my 
 server (which obviously doesn't have the same IP address)?
Another way would be this:

1. connect to a server using a TCP socket (for example, google.com or 
anything else that goes through your desired interface)
2. after connection, read the IP address (client address) from the 
socket object

IMHO if you wish to operate a server, you should either bind to all IP 
addresses, or know your real IP address.

   Laszlo

-- 
http://mail.python.org/mailman/listinfo/python-list