From: Florian Forster Date: Thu, 1 Jun 2006 20:17:19 +0000 (+0200) Subject: Don't call bind when opening a socket. X-Git-Tag: liboping-0.2.1~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=78164c719fbd60c9c7db7bd11477fde6efe5edba;p=liboping.git Don't call bind when opening a socket. The call to bind, thoug working fine under GNU/Linux, seems not to work under other operating systems. It didn't work under FreeBSD and Mac OS X with the `bind' call but without. I think `bind' may only be neccessary if we want to bind to a specific interface. It might be a good idea to add the possibility later, so I only commented the code for now. --- diff --git a/src/liboping.c b/src/liboping.c index 6dbb73f..debd432 100644 --- a/src/liboping.c +++ b/src/liboping.c @@ -1021,6 +1021,12 @@ int ping_host_add (pingobj_t *obj, const char *host) continue; } +/* + * The majority vote of operating systems has decided that you don't need to + * bind here. This code should be reactivated to bind to a specific address, + * though. See the `-I' option of `ping(1)' (GNU). -octo + */ +#if 0 if (bind (ph->fd, (struct sockaddr *) &sockaddr, sockaddr_len) == -1) { dprintf ("bind: %s\n", strerror (errno)); @@ -1029,6 +1035,7 @@ int ping_host_add (pingobj_t *obj, const char *host) ph->fd = -1; continue; } +#endif assert (sizeof (struct sockaddr_storage) >= ai_ptr->ai_addrlen); memset (ph->addr, '\0', sizeof (struct sockaddr_storage));