Re: Socket Send and Receive Thread Safety
From: Eugene Gershnik (gershnik_at_hotmail.com)
Date: 02/24/05
- Next message: Eugene Gershnik: "Re: wininet question"
- Previous message: Mangala: "wininet question"
- In reply to: Nizar: "Socket Send and Receive Thread Safety"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Feb 2005 16:44:35 -0800
Nizar wrote:
> Is it safe for one thread to call Socket.Receive and another to call
> Socket.Send on the same Socket at the same time?
Should be fine unless .NET library "designers" screwed things up completely.
> The documentation says that instance members are not guaranteed to be
> thread safe, but I'm not sure whether this combination is or not.
This is just a general warning for all .NET crap^H^H^H^H classes that tells
you that they don't do this:
public some_method()
{
lock(this);
....
unlock(this);
}
in every method. Once upon a time in a land called Java class library
something like the code above was considered a good idea. They got smarter
since.
What it means that it is not a good idea to call methods that _modify_
socket (so called mutating methods) simultaneously with other methods
without explicit locking. Recv and Send are usually considered non-mutating
methods so they should be fine. In better languages there is a little word
"const" that tells you which methods are mutating.
> I've also heard that the send and receive buffers are disparate and
> can be accessed simultaneously.
Should be the case for anything usefull.
-- Eugene
- Next message: Eugene Gershnik: "Re: wininet question"
- Previous message: Mangala: "wininet question"
- In reply to: Nizar: "Socket Send and Receive Thread Safety"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|