Re: Async socket & active connections
- From: "DeveloperX" <nntpDev@xxxxxxxxxxxxx>
- Date: 26 Mar 2007 02:44:27 -0700
On 25 Mar, 21:48, "atlaste" <atla...@xxxxxxxxx> wrote:
Hi,
In an attempt to create a full-blown webcrawler I've found myself
writing a wrapper around the Socket class in an attempt to make it
completely async, supporting timeouts and some scheduling mechanisms.
I use a non-blocking approach for this, using the call to 'poll' to
support the async mechanism - rather than the 'begin' and 'end'
functions. I already found that connecting doesn't set the
"isconnected" variable correctly (SocketException is thrown: non-
blocking has this effect...) - but doesn't appear to be a problem
because poll, read and write work fine.
For measuring the performance of the crawler, I started "perfmon.msc"
and added the "active connections" item from object "TCP". After a
while I found the number of this performance counter to reach over
300K connections (!), enough to start worrying...
My crawler is designed to support around 200 connections simultaneous.
"netstat -an" doesn't support this finding, but does show hundreds of
connections that are in either "CLOSE_WAIT", "FIN_WAIT_2" or another
closing state.
After a host has completed, I try to disconnect the TCP/IP connection.
I've attempted combinations of "shutdown(both)", (async) "disconnect"
and "close(0)" - where no combination appears to have the desired
effect. When the application is shut down, all connections (including
the CLOSE_WAIT connections) are removed. The FIN_WAIT_2 connections
linger forever...
Perhaps someone knows a solution to this problem?
Greetings,
Stefan de Bruijn.
Just a guess, can you try it with keepalive set to 0?
Something like where s is a Socket:
s.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IP,
System.Net.Sockets.SocketOptionName.KeepAlive, 0);
.
- Follow-Ups:
- Re: Async socket & active connections
- From: atlaste
- Re: Async socket & active connections
- References:
- Async socket & active connections
- From: atlaste
- Async socket & active connections
- Prev by Date: Re: Working with a VB COM Component
- Next by Date: Re: SuspendLayout Not Suspending...
- Previous by thread: Async socket & active connections
- Next by thread: Re: Async socket & active connections
- Index(es):
Relevant Pages
|