Home All Groups Group Topic Archive Search About

Socket Doesn't Accept New Connection After Some Time

Author
24 Jan 2006 2:21 PM
Zeeshan Gulzar
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

Author
24 Jan 2006 5:07 PM
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 )
--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

Show quote
"Zeeshan Gulzar" <ZeeshanGul***@discussions.microsoft.com> wrote in message
news:B7300147-20B9-4391-9E0F-CFFE7D47C5CB@microsoft.com...
>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

AddThis Social Bookmark Button