>A cross-platform solution (though a kludgy one) would be to open up a
ServerSocket on
>port n, then have a Socket open up a connection to localhost:n, then read
the IP with
>Socket.getLocalAddress().  Will that work?

Not with windows sockets in my experience,
Windows figures that any local requests(i.e.: to 192.168.0.1:2587) are to
your LAN or equivalent, it'll connect with 192.169.0.1 or similar,
Certainly when I've programmed anything that needs the local IP its been the
following procedure:
(windows of course, but I figure there's a windows way, and a Linux way, for
Linux there now follows a total guess)
<total guess>the Linux way might be going through the eth's in proc or
wherever all those are listed and getting each eth's IP address that its
bound to</total guess>

for windows,(typing from memory here, hopefully I remember these function
names right),
 I make a (Winsock.dll) dll call to gethostbyname() with the local host
name, which returns a HOSTENT structure, the h_addr_list then contains a
null terminated list of every ip, the one which isn't 192.168.? is the
address to use, except AOL users, who have 2 IP addresses for some damn
reason, one at 63.? which doesn't work, and one at 172.? which does, so if
there's more than one IP either select 172.? (unsafe), or fall back to the
original(ugly) method of making a connection to auto.search.msn.com
(huge number of connections at any time from dns not found's and
autosearches so they wont notice a few million extra considering the number
of users they have, and if you worked out freenet users by requests to
auto.search.msn.com,that would be everyone who uses iexplore, as we all get
them every day).


_______________________________________________
Devl mailing list
Devl at freenetproject.org
http://lists.freenetproject.org/mailman/listinfo/devl

Reply via email to