[EMAIL PROTECTED] wrote, On 2008-02-26 15:09: > On Feb 15, 4:39 pm, "Wan-Teh Chang" <[EMAIL PROTECTED]> wrote: >> On Fri, Feb 15, 2008 at 2:35 AM, D3||||!$ <[EMAIL PROTECTED]> wrote: >>> Hi All!!! >>> I am looking for a standard NSS/NSPR function which when called should >>> return and/or the local IP address and the port number to which SSL is >>> bound on the system. >> Use the NSPR function PR_GetSockName: >> http://developer.mozilla.org/en/docs/PR_GetSockName >> http://www.mozilla.org/projects/nspr/reference/html/priofnc.html#19250 >> >> Wan-Teh > > i have the same question, i need the Local IP.
THE local IP? Your question seems to presume that there is only one. There may be many. When you connect a socket, one of the system's local IP addresses becomes bound to it. After that, PR_GetSockName will tell you the local IP address to which it is bound. > I create a socket, call PR_GetSockName, it returns 0.0.0.0 (on a mac > with a recent, but not the most recent release of NSPR) Your socket is not yet connected, hence it has none of your system's IP addresses bound to it. > so, not only is this not working, It's working as it is designed and intended to work. > but this should not be the way to do this anyway, > there should be a way to get the local IP without creating a socket. THE local IP? Which one? Unfortunately, although nearly all systems implement the common sockets API, they do not all implement the same APIs for asking "what local IP addresses does my system have"? One technique, that works on some systems but not Windows, is to run the command "netstat -in" and take the IP addresses out of its output. But this is trickier than it sounds, especially on Unix or Linux, because it's difficult to get all aspects of running another program and collecting its output right on those systems. (Just look at these bugs: https://bugzilla.mozilla.org/show_bug.cgi?id=51429 https://bugzilla.mozilla.org/show_bug.cgi?id=182758 https://bugzilla.mozilla.org/show_bug.cgi?id=174993 Another technique is to get IP addresses out of the local system's routing table, but the methods for doing this vary by platform also. I think the command "netstat -rn" will get routing table info on most systems. But the output format will vary by system. _______________________________________________ dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto