server: bind to device, too

This commit is contained in:
Tim Niemeyer 2018-04-03 19:37:27 +02:00
parent 92456d0370
commit 46d03b86a6
1 changed files with 5 additions and 0 deletions

View File

@ -45,6 +45,11 @@ void macNockServer_run()
return;
}
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, g_interface, strlen(g_interface)) < 0)
{
perror("[c] WARNING: Can't bind to device");
}
// allow to reuse the port immediately as soon as the service exits.
int sockoptval = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &sockoptval, sizeof(int)) != 0)