Tcp socket connect error after bind on Solaris OS
Hi All,
I am trying to "connect" to our Tcp Server program from our client code, after "binding" the port of client socket. It is our requirement to fix same port of connect socket. So we use
int on = 1;
setsockopt(sk,SOL_SOCKET,SO_REUSEADDR, &on, sizeof(on));
before connet().
But if we kill and restart the client program again, we get connect error.
"connect error!: Address already in use"
We check the the TCP socket status by netstat. It is showing that when we kill client program, that tcp socket goes to TIME_WAIT state, but does not return to ESTABLISHED, immediately if we restart client socket. We know, normarly TIME_WAIT state will be for 2MSL, and that's why we use SO_REUSEADDR. Seems then SO_REUSEADDR does not work properly.
But same code we tested in Linux kernel 2.6, and working fine.
Any insights is much appreciated
Bye