1

I am working on a console server app that listens on a port for a incoming connections. Every time I restart the console app, it has a pending connection queue which is causing the console server app to crash.

Is there a way to remove all pending connections in the queue before accepting new connections ?

NewUnhandledException
  • 733
  • 2
  • 10
  • 34
  • this answer might help. http://stackoverflow.com/questions/12231789/cancel-blocking-accepttcpclient-call/12489289#12489289 – th1rdey3 Sep 25 '12 at 10:43
  • Causes it to crash how? The pending connection queue does not survive the closing of the listening socket. Post your problem, not your diagnosis. – user207421 Sep 25 '12 at 12:11

1 Answers1

0

Your server app needs to set SO_REUSEADDR socket option:

server_socket.SetSocketOption( SocketOptionLevel.Socket,
    SocketOptionName.ReuseAddress, true );

to be able to bind the listening port after restart.

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171