[Mono-dev] Thread safety of System.Net.Sockets.Socket

Robert Jordan robertj at gmx.net
Sat Jan 31 08:10:21 EST 2009


k0l0b0k.void wrote:
> Hi guys, I have little question: MSDN documentation tells that any 
> instance member of Socket class is thread-safe 
> (http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx). 
>   But according to Mono documentation 
> (http://www.go-mono.com/docs/index.aspx?link=T%3ASystem.Net.Sockets.LingerOption) 
> Socket members is not thread-safe.
> Is it real? Should I synchronize Socket operations manually? (in 
> particular I'm interesting in ReceiveFrom and SentTo methods on UDP socket).

The docs of MS.NET 1.1 state that the Socket class is not thread safe,
but in fact it is (in Mono and MS.NET). It looks like Mono's docs
were not updated.

Anyway, for best performance you should rather use 
{Begin|End}ReceiveFrom/{Begin|End}SentTo.

Robert



More information about the Mono-devel-list mailing list