S
Sin
I've got my daemon doing everything it should, except I can't find a clean
Had the same problem 2 weeks ago... Check out SO_REUSEADDR... Here's an
example :
// ... open socket ...
BOOL reuse= 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(BOOL))
< 0) {
printf("setsockopt() failed\n");
exit(-1);
}
// ... bind socket ...
Alex.
way to unbind a port from a socket that's bound and listening. This doesn't
keep the program from working, but it means that if it exits I can't
immediately re-run it (since I have to wait for the port to unbind on it's
own). If I ctrl-c out of it (while it's not in the middle of
communications) it works fine, but otherwise if I try to find any way to
exit gracefully, it doesn't unbind the port.
Anyone have a suggestion? I tried the shutdown feature, but it didn't seem
to have any effect that I could see... and nothing else looks useful (and
all online searches just turn up third-party libraries that I don't care to
use). There must be some simple way to do this...
Had the same problem 2 weeks ago... Check out SO_REUSEADDR... Here's an
example :
// ... open socket ...
BOOL reuse= 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(BOOL))
< 0) {
printf("setsockopt() failed\n");
exit(-1);
}
// ... bind socket ...
Alex.