Don't call bind when opening a socket.
[liboping.git] / src / liboping.c
index c6e9df5..debd432 100644 (file)
@@ -370,7 +370,7 @@ static int ping_receive_one (int fd, pinghost_t *ph, struct timeval *now)
                return (-1);
        }
 
-       dprintf ("Read %i bytes from fd = %i\n", buffer_len, fd);
+       dprintf ("Read %u bytes from fd = %i\n", (unsigned int) buffer_len, fd);
 
        if (sa.ss_family == AF_INET)
        {
@@ -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));