On Monday, February 23, 2004, at 07:27 PM, Ronald F. Guilmette wrote:
Given a socket which has been properly created, opened, and then bound to some port and the special INADDR_ANY ``wildcard'' address, I need to be able to them programatically find all of the IPv4 addresses that the socket was just bound to.
Can anyone suggest a way to do this?
Can anyone suggest a way to do this easily?
Can anyone suggest a way to do this portably?
So I understand what you want, I'll rephrase: you want to find all the IPv4 addresses that have been assigned to devices on the local host. To pick nits, that socket was just bound to INADDR_ANY, not "all the address" on the host. Once a connection is accepted, that socket is bound based, probably, on the interface that accepted the request, or the destination address of that request.
You can find the addresses on the host, in recent BSDs and Linux (AFAIK) with 'getifaddrs()', which is fairly easy to use, and fairly portable (although it's relatively new). Check the man page. You don't need to fuss with sockets to do this (but I'm not sure that is important to you).
Does that help?
Regards,
Justin
-- Justin C. Walker, Curmudgeon-At-Large * Institute for General Semantics | Men are from Earth. | Women are from Earth. | Deal with it. *--------------------------------------*-------------------------------*
_______________________________________________ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "[EMAIL PROTECTED]"