[Mono-dev] fix for bug #358987 in 1.9?

Robert Jordan robertj at gmx.net
Wed Feb 20 12:35:29 EST 2008

Avery Pennarun wrote:
> 2008/2/20 Steve Bjorg <steveb at mindtouch.com>:
>> - s.Shutdown (SocketShutdown.Both);
>> + try {
>> + s.Shutdown (SocketShutdown.Both);
>> + } catch(Exception e) {
>> + // log here?
>> + }
>>   s.Close ();
> Why call Shutdown() at all?  The shutdown syscall is only useful if
> you need to keep the fd around longer (eg. if someone else is still
> holding onto it and you don't want it to be reused).  In the above
> code, close() shuts down the socket anyway.

Close(2) will fail with EINTR if there are still pending receptions
and/or sendings. That's why usually shutdown(2) is called, followed by
a loop until close(2) does not return EINTR anymore, because shutdown
does not kill current recvs/sends.

I don't know how mono is handling this internally but the patch
above looks OK to me. Even MSDN clearly states that Shutdown
must be called unless linger is turned on.


More information about the Mono-devel-list mailing list