Re: How do I get my own IP address?
- Posted by useless Sep 21, 2009
- 2333 views
I didn't mean to ask for a definition, i was trying to convey the meaning of the word "how" when i asked him to "spill it". In what way or manner or by what method does Jeremy specify which nic to use to contact the world outside the computer, and by using what Eu code.
Hm, contacting the world outside the computer is not so hard. To allow the outside world to connect to you is not so hard either, just bind to 0.0.0.0. Now, when it comes to binding only to a particular address of the many available, you pretty much have to have a config file and let the user choose or specify on the command line.note
All of that, though, is not determining your local address. If you truly need to do that intelligently, then you need to filter out some common standards such as 192...., 10..., etc...
Jeremy
Filter in what where?
From Greg's eucode:
This might work for you:
include std/pretty.e include std/net/dns.e constant COMPUTERNAME = getenv("COMPUTERNAME") pretty_print( 1, host_by_name(COMPUTERNAME), {2} )
{ "example-computer", "", { "192.168.1.90" }, 2 }
-Greg
[/quote]
So by running that code, and not printing out the ip, i have selected which nic the computer will use to send my http request to the world? I fail to see how that will happen.
Filter on or filter out the 192.168.1.90, etc.
... and by using what Eu code.
Untested concept code:
include std/pretty.e include std/net/dns.e constant COMPUTERNAME = getenv("COMPUTERNAME") sequence ips = host_by_name(COMPUTERNAME) for i = 1 to length(ips[3]) do if match("192.", ips[3][i]) = 1 then -- filter elsif match("10.", ips[3][i]) = 1 then -- filter -- and so on end if end for
Note: I did not look up the output format of host_by_name()'s return value.
Again, how does printing this out, or not print it out, tell winxp which nic to talk to the outside world with?
useless