With ERef, if no hostname is defined in reflect.conf then it uses
gethostname() then gethostbyname() then gethostbyaddr() to normalize the
hostent. If one hostname is defined then it check to see if it's an ip
address (inet_addr(hostname)) and if not does gethostbyname() and
gethostbyaddr(). It then attempts to use that as bind_ip, if the first bind
fails bind_ip is set to INADDR_ANY (0.0.0.0), which usually ends up to be
the first defined TCP/IP interface under
HKEY_LOCAL_MACHINE->System->CurrentControlSet->Services->Class->NetTrans.
>gethostbyname(), you can step thru the address pointers I suppose. But
>then again, how do you CHOOSE which one to use? How does a program choose
>which bind_ip to use if there are multiple IPs available and they don't
>ask the user to choose one? Do they just use the first one? If they use
>h_addr in the hostent struct to get the first one, what determines the
>order? It seems like it'd be much easier to throw up an option allowing
>the user to choose which IP to bind to.
>
>Again, this problem never occured when there was only one numerical IP
>address bound to a computer which would be my guess as to why the
>programmers never thought much about it. If I understand it right, it's
>only a problem because each client also acts as a server..sending AND
>receiving data with the IP address embedded within the packets on top of
>the IP address in the header.
>
>--
>streak@ccwf.cc.utexas.edu * Jason Williams -- Austin, Tx. | |
>streak@mail.utexas.edu * University of Texas at Austin | ___ |
>streak@cs.utexas.edu * BS Computer Science \_|_/
>*************** http://ccwf.cc.utexas.edu/~streak/ **************|
>
>