As we all know the unlink() trick only works on AF_UNIX sockets of the sort which appear as actual files in the filesystem...
For AF_INET sockets, there is no filesystem token representing them; only a list of bound ports/IPs kept track of by the kernel...
For all TCP servers, it's common and recommended to also setsockopt(SO_REUSEADDR), which will allow a recently terminated and active server to re-bind the same listening port, even if there are lingering TIME_WAIT sockets on that port#... So, that will probably solve the problem here...
So, just set SO_REUSEADDR, and all should be well... <just before you bind(), do:>
Syntax::
int on = 1; setsockopt (sd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on));
where, sd stands for Socket Fd.
It looks like you're new here. If you want to get involved, click one of these buttons!