1
0
mirror of https://github.com/irssi/irssi.git synced 2024-08-04 03:34:18 -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:
Timo Sirainen 2002-11-29 13:38:21 +00:00 committed by cras
parent b669dfaaaa
commit bae71dff48

View File

@ -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;
}
}