diff options
author | Timo Sirainen <cras@irssi.org> | 2002-11-29 13:38:21 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-11-29 13:38:21 +0000 |
commit | bae71dff48507fadb62ffa0807fcf6440e8d2004 (patch) | |
tree | f587f4f8ffc84eb6ad597553c39cda4773596a1f /src/core | |
parent | b669dfaaaa8d22fc9713abc9c729f679302a7e63 (diff) | |
download | irssi-bae71dff48507fadb62ffa0807fcf6440e8d2004.zip |
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
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/network.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/network.c b/src/core/network.c index b2b7fc3e..f5a6608b 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -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; } } |