mirror of
https://github.com/irssi/irssi.git
synced 2024-09-08 04:26:01 -04:00
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 */
|
||||
if (my_ip != NULL) {
|
||||
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 */
|
||||
sin_set_ip(&so, NULL);
|
||||
bind(handle, &so.sa, SIZEOF_SOCKADDR(so));
|
||||
int old_errno = errno;
|
||||
|
||||
close(handle);
|
||||
errno = old_errno;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user