- if (bind_portrange(s, &name, 512, IPPORT_RESERVED - 1, "udp") == 0)
- goto out;
+ if (bind_portrange(s, &name, (in_port_t)512,
+ (in_port_t)(IPPORT_RESERVED - 1), "udp") == 0)
+ goto out;
+ dbprintf(("%s: dgram_bind: Could to bind to port in range: 512 - %d.\n",
+ debug_prefix(NULL), IPPORT_RESERVED - 1));
+
+ name.sin_port = INADDR_ANY;
+ if (bind(s, (struct sockaddr *)&name, (socklen_t)sizeof(name)) == 0)
+ goto out;
+ dbprintf(("%s: dgram_bind: Could to bind to any port: %s\n",
+ debug_prefix(NULL), strerror(errno)));
+
+ if (retries >= BIND_CYCLE_RETRIES) {
+ dbprintf(("%s: dgram_bind: Giving up...\n", debug_prefix(NULL)));
+ break;
+ }