22 const uint16_t port) {
24 int sock = socket(AF_INET, SOCK_DGRAM, 0);
27 " address " << addr <<
", port " << port
28 <<
", reason: " << strerror(errno));
31 if (fcntl(sock, F_SETFD, FD_CLOEXEC) < 0) {
34 <<
" on fallback socket for address " << addr
36 <<
", reason: " << strerror(errno));
39 struct sockaddr_in addr4;
40 memset(&addr4, 0,
sizeof(addr4));
41 addr4.sin_family = AF_INET;
42 addr4.sin_addr.s_addr = htonl(addr.
toUint32());
43 addr4.sin_port = htons(port);
45 if (bind(sock,
reinterpret_cast<struct sockaddr*
>(&addr4),
49 char* errmsg = strerror(errno);
53 " address " << addr <<
", port " << port
54 <<
", reason: " << errmsg
55 <<
" - is another DHCP server running?");
60 if (fcntl(sock, F_SETFL, O_NONBLOCK) != 0) {
63 char* errmsg = strerror(errno);
66 " fallback socket, bound to " << addr <<
", port "
67 << port <<
", reason: " << errmsg);