forked from PsychoticNinja/irssi
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:
parent
1ca2218e46
commit
9abd857618
@ -196,10 +196,14 @@ GIOChannel *net_connect_ip(IPADDR *ip, int port, IPADDR *my_ip)
|
|||||||
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
|
setsockopt(handle, SOL_SOCKET, SO_KEEPALIVE,
|
||||||
(char *) &opt, sizeof(opt));
|
(char *) &opt, sizeof(opt));
|
||||||
|
|
||||||
/* set our own address, ignore if bind() fails */
|
/* set our own address */
|
||||||
if (my_ip != NULL) {
|
if (my_ip != NULL) {
|
||||||
sin_set_ip(&so, my_ip);
|
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 */
|
/* connect */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user