On Wed, 9 Jan 2002 21:53:23 +0200 centipede <[EMAIL PROTECTED]> wrote:
> > > Hello, > > According to Richard Stevens in Unix Network Programming (Vol 1) the > way a process can find out its host own IP (or IPs) is to call uname() > or gethostname() and feed the result to gethostbyname(). > The problem is that this way certainly can't deal with dynamic IPs > on ppp connections, for example. > How d'ya people handle this issue ? > > thx, > centipede. > I know too ways to do that. The first (and better) way is to lookup the route tables, and choose the default route, to send packets with source IP of outgoing interface. The second is to connect to a remote host, and use the getsockname() function to return infos on outgoing interface, which I think, is a bad way. ______________________________________________________________________ __ __ / || \ FreeBSD Network - http://www.GomoR.org/ | __ |___/ Security Engineer Junior | || \ \__|| \ >root is the only God I believe in<