That's not our situation, but it's news to me so I'd like to clarify: If
we create a thread which calls BeginSend sucessfully
(CompletedSynchronously == false) then terminates, then EndSend will
complete indicating a cancellation. I've used completion port before (in
my C++ and Win32 days) and I can't remember coming across this. Moreover,
I can't see why this should be...

Back to the subject - what we're seeing is a heap which (eventually)
contains about 500 MB of free space. If you dump the heap (using WinDbg
and 'SonofStrike') you see the pattern:

<free space><IO buffer><free space><IO buffer><free space>....etc.

The IO buffers are each just one or two hundred bytes. Each is kept in
memory by a Pinned GCHandle from an asynchronous Send operation. The
System.Net.Sockets are shutdown an closed and the Socket handles are all
freed. Looking at the framework code with reflector it seems that on
receiving the callback from the OS, the framework should unconditionally
unpin the send buffer before invoking our callback. It's clear that that
isn't happening in this case.

Garry

On Mon, 26 Jul 2004 05:22:42 -0500, Mark Smith <[EMAIL PROTECTED]> wrote:

>Correct.
>
>.NET utilizes the I/O completion port asynchronous socket model
>(WSASend/WSARecv) and therefore has the same restrictions as unmanaged
code
>using that model. One of those restrictions is that the thread initiating
>the socket operation cannot terminate before it is completed or the asynch
>operation is canceled.  This is a behavior of I/O completion ports - not
of
>.NET itself.  You should still get the callback, but when EndSend is
called,
>it should throw an exception indicating that the operation was canceled.
>
>If you have scenarios where your own threads might exit with pending I/O
>events you will either need to ensure they stick around or post the work
to
>a thread pool (ThreadPool.QueueUserWorkItem) and initiate the BeginSend
from
>there.  The CLR will ensure that the thread will stick around in that case
>(it tracks overlapped I/O from the threadpool threads).
>
>Best Regards,
>Mark Smith
>

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to