Use the last used interface address for the socket address.

This allows the correct address to be put in the server info packet
allowing nq to work on multi-homed hosts. More testing needs to be done to
ensure nothing is broken, or better yet, a rewrite of the networking code
to properly associate the information with the packets.
This commit is contained in:
Bill Currie 2011-08-06 21:47:57 +09:00
parent ae9404cc27
commit 805256ff65

View file

@ -514,8 +514,11 @@ UDP_GetSocketAddr (int socket, struct qsockaddr *addr)
getsockname (socket, (struct sockaddr *) addr, &addrlen);
a = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
if (a == 0 || a == inet_addr ("127.0.0.1"))
((struct sockaddr_in *) addr)->sin_addr.s_addr = myAddr;
if (a == 0 || a == inet_addr ("127.0.0.1")) {
((struct sockaddr_in *) addr)->sin_addr.s_addr = *default_iface;
if (last_iface)
((struct sockaddr_in *) addr)->sin_addr.s_addr = *last_iface;
}
return 0;
}