Socket Doesn't Accept New Connection After Some Time

G

Guest

I am using C#.NET and i made a windows service which is running in
background. This service opened a socket (Listener) on a specified port at
startup. Client connected to this port and send a message to listener and
close the socket again client connect after some time maybe after 5 minutes
or above and send another message to listener and close the socket. (Socket
is Accpeted, Send & Receive data Asynchronously)

This service work fine for a period of time. But after that

Question: Socket does not accept new connection while socket is in listening
state.
Whenever i want to connect to this socket (either by Telnet or by my client
on lan or wan or even by local-loop) the exception is occured.

Error Code: WSAECONNREFUSED 10061
Description: No connection could be made because the target computer
actively refused it.


After restart the service, socket works fine again for some period of time.

Is there any solution.
Thanks in advance
 
V

Vadym Stetsyak

It seems like socket stopped listening, what info
cmd netstat -an -p tcp returns about the address and port
you're listeting on?

When you receive WSAECONNREFUSED is socket in the blocking Accept call?
Is Accept throwing exceptions in your case?

Additionaly you can enanble network tracing ( in .NET 2.0 )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top