Re: How to get client IP address assigned by Cisco VPN client
Re: How to get client IP address assigned by Cisco VPN client
- Subject: Re: How to get client IP address assigned by Cisco VPN client
- From: "Justin C. Walker" <email@hidden>
- Date: Sun, 23 Apr 2006 15:50:40 -0700
On Apr 23, 2006, at 13:06 , Duane Murphy wrote:
--- At Thu, 20 Apr 2006 13:33:57 -0700, Josh Graessley wrote:
A couple of comments:
I have an interesting situation that I've been trying to solve.
Please don't hijack threads. It is bad for those that try to keep
their lists "threaded", and it can cause problems (e.g., those that
just delete threads that aren't interesting to them will miss your
questions; and it confuses the archival record).
I have a small http server open on a socket. But I need to send a
message to another machine that indicates what the address is that
they
are to connect to in order to use this http server. The information is
specified to be a complete URL.
I open the listening socket for the http server using INADDR_ANY.
When I
use getsockname() I get INADDR_ANY (ie 0 (I think)) for the IP
address.
Needless to say, this isn't useful.
Code snippets help. This is pretty vague, but the first thought that
occurs to me is that, as long as you look at the listening socket,
you will see what you "registered" when you did the listen call
(unless you asked for port 0, in which case, the returned structure
will show you a valid port). This is as it should be, because the
listening port is uncommitted, beyond your requirements. INADDR_ANY
says "I don't care", so the presumption is that you still don't
care. In addition, the system will continue to not care. This way,
your request (INADDR_ANY) will continue to be honored.
Another way of looking at it is that there really isn't an endpoint
until a client connects (and even then, the listening socket won't
have a local address if you haven't provided one; the 'accept'ing
socket will have a valid local address). If you want to restrict
clients to a specific (local) IP address, you should use that in your
listen() (and that is the IP address you will see when you
'getsockname()').
What is the best way for me to get the IP address that the other end
would use? Would a routing socket be the best way? But doesn't that
require root/authenticated access? Is there another, simpler way?
Your system has a bunch of IP addresses, so you are going to have to
tell your clients which address to use. For example, here in my home
network, my main system has several IPv6 addresses and several IPv4
addresses. The v4 addresses include: globally routable IP address
(assigned by my IP), and one private IP address for each of several
interfaces. In fact, the interface to the outside world has several
IP addresses itself, for some fiddling I am doing locally. That is
why the system won't be able to guess which IP address your code
really wants to listen on.
Hope that makes sense.
Regards
Justin
--
Justin C. Walker, Curmudgeon-at-Large
() The ASCII Ribbon Campaign
/\ Help Cure HTML Email
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden