Socket weirdness
- From: "William Stacey [MVP]" <william.stacey@xxxxxxxxx>
- Date: Sun, 17 Sep 2006 19:41:02 -0400
See some strange results on Send and peer with a closed Receive. Setup a
test harness. Server accepts socket, then just does a Shutdown.Receive
right away and waits. The client socket does both blocking Sends and
BeginSends to see the difference in behavior.
Results:
1) Using blocking Sends - The first send returns 10, which is the buffer
size. Future Sends, return 0 and no exception. This behavior seems not to
fly with the doco. The send should block until 10 bytes are sent to kernel
mode or throw an exception, *not return 0. Note the socket is in blocking
mode (default setting).
2) Using async BeginSend gives completly different results. The first
EndSend returns 10 as above. The second BeginSend returns a null
IAsyncResult and sets SocketError to "ConnectionReset". I find this
behavior very strange. BeginSend should never return a null IAsyncResult as
that FooBars the async pattern (it should always return IAsync or
exception). It should save the exception for the EndSend call. Second, why
does it set SocketError to ConnectionReset, when blocking Send does not seem
to care. The two behaviors should be consistent.
3) Also, what is the point of SocketError being an out parm? It should just
be included in the SocketException and thrown - no?
TIA
--
William Stacey [MVP]
.
- Follow-Ups:
- Re: Socket weirdness
- From: Dave Sexton
- Re: Socket weirdness
- From: William Stacey [MVP]
- Re: Socket weirdness
- Prev by Date: Re: Garbage collection
- Next by Date: Re: Socket weirdness
- Previous by thread: Garbage collection
- Next by thread: Re: Socket weirdness
- Index(es):
Relevant Pages
|