forked from PsychoticNinja/irssi
If bind() fails when connecting, don't fallback to default address. Should
make it easier to notice invalid settings or figure out why it's not working.. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3032 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
b669dfaaaa
commit
bae71dff48
@ -201,10 +201,13 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
|
|||||||
/* set our own address */
|
/* set our own address */
|
||||||
if (my_ip != NULL) {
|
if (my_ip != NULL) {
|
||||||
sin_set_ip(&so, my_ip);
|
sin_set_ip(&so, my_ip);
|
||||||
if (bind(handle, &so.sa, SIZEOF_SOCKADDR(so)) == -1) {
|
if (bind(handle, &so.sa, SIZEOF_SOCKADDR(so)) < 0) {
|
||||||
/* failed, set it back to INADDR_ANY */
|
/* failed, set it back to INADDR_ANY */
|
||||||
sin_set_ip(&so, NULL);
|
int old_errno = errno;
|
||||||
bind(handle, &so.sa, SIZEOF_SOCKADDR(so));
|
|
||||||
|
close(handle);
|
||||||
|
errno = old_errno;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user