I have a small problem which I was wondering if anyone could help with.
I have written socket client server processes in which I am finding if the
server shuts down before the client then when I attempt to start up the
server again I get a bind error saying the address is in use. If I wait up
to 30sec and execute the server again it will work.
I believe this is because the server shutdown before the client (in this
case unavoidable) and the OS holds the address for a period of time.
I have sent this problem in AIX, Sun, Linux and now NTO.
Anyone got any suggestions?
Cheers Ben.
Benjamin Rogers <brogers@nospam.patrick.com.au> wrote:
: I have a small problem which I was wondering if anyone could help with.
: I have written socket client server processes in which I am finding if the
: server shuts down before the client then when I attempt to start up the
: server again I get a bind error saying the address is in use. If I wait up
: to 30sec and execute the server again it will work.
: I believe this is because the server shutdown before the client (in this
: case unavoidable) and the OS holds the address for a period of time.
: I have sent this problem in AIX, Sun, Linux and now NTO.
: Anyone got any suggestions?
set the SO_REUSEADDR socket oprion before the bind:
int on = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on);
-seanb