1
0
mirror of https://github.com/irssi/irssi.git synced 2024-08-04 03:34:18 -04:00

net_connect(): if bind() fails, set the address back to INADDR_ANY to make sure it doesn't leave the socket in buggy state.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1978 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-07 14:35:00 +00:00 committed by cras
parent 1ca2218e46
commit 9abd857618

View File

@ -196,10 +196,14 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
(char *) &opt, sizeof(opt));
/* set our own address, ignore if bind() fails */
/* set our own address */
if (my_ip != NULL) {
sin_set_ip(&so, my_ip);
bind(handle, &so.sa, SIZEOF_SOCKADDR(so));
if (bind(handle, &so.sa, SIZEOF_SOCKADDR(so)) == -1) {
/* failed, set it back to INADDR_ANY */
sin_set_ip(&so, NULL);
bind(handle, &so.sa, SIZEOF_SOCKADDR(so));
}
}
/* connect */