Strange socket problems

elektrobank

Member
Joined
Aug 11, 2008
Messages
19
Programming Experience
10+
I have a server I wrote using Asynchronous sockets. In the piece that accepts new connections I am getting a problem where some users are saying that some of the times they get this error on the server when the client tries to re-connect to the server:

"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"

After this error occurs the server goes dead and no new clients can connect until I physically quit the server program and start it again. So what should I do when I get this error? I tried to essentially restart the server in my code by closing the socket (listener.Close()) and then calling the same code I used to create and bind to the socket in the beginning, but then I get an error saying that I can't bind to the same port again.

So, two questions. First off, what is the proper way to handle that code and prevent it from essentially killing my server? Next, what is the proper way to restart a server through my code? Just calling .close() on the listener and then starting it again doesn't work in this case.

Thanks
 
Back
Top