windows:
BOOL bReuseaddr=TRUE;
setsockopt (s,SOL_SOCKET ,SO_REUSEADDR,(const char*)&bReuseaddr,sizeof(BOOL));
Linux
int opt = 1;
setsockopt(LisSockfd,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof( opt ));
Setting the socket property to SO_REUSEADDR (allowing the socket to bind with an address already in use) fixes the bind failure!