+ if((nfd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0)
+ {
+ syslog(LOG_ERR, _("Creating metasocket failed: %m"));
+ continue;
+ }
+
+ flags = fcntl(nfd, F_GETFL);
+ if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
+ {
+ close(nfd);
+ syslog(LOG_ERR, _("System call `%s' failed: %m"),
+ "fcntl");
+ continue;
+ }
+
+ /* Optimize UDP settings */
+
+ option = 1;
+ setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
+#ifdef HAVE_LINUX
+ if(get_config_string(lookup_config(config_tree, "BindToInterface"), &interface))
+ if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, interface, strlen(interface)))
+ {
+ close(nfd);
+ syslog(LOG_ERR, _("Can't bind to interface %s: %m"), interface);
+ continue;
+ }
+#endif