The documentation says that instance members are not guaranteed to be thread
safe, but I'm not sure whether this combination is or not.
I've also heard that the send and receive buffers are disparate and can be
accessed simultaneously.
Mike
"Nizar" <Ni...@discussions.microsoft.com> wrote in message
news:761C5E06-EAFF-4B6D...@microsoft.com...
Regards,
-Ron
His comments merely state (correctly) that you can't pass a CSocket object
across thread boundaries. The reason is the same as the reason why you
can't pass most handle-based MFC objects (like CWnd's etc) across thread
boundaries: all of MFC's handle-based objects are stored in thread-local
storage and therefore MFC will fail to find the object when it does a call
to FromHandle.
His solution is the time-honored solution that's also explained at the MSDN
KB at http://support.microsoft.com/kb/175668/EN-US/ : don't pass the MFC
object; rather, call Detach and then pass the underlying handle to the
object. That works in all cases.
But it's unrelated to the original question about thread safety.
Mike
"RNEELY" <RNE...@discussions.microsoft.com> wrote in message
news:7956FA21-6EEC-465A...@microsoft.com...
"Michael K. O'Neill" <MikeAT...@nospam.hotmail.com> wrote in message
news:uZDplqTG...@TK2MSFTNGP10.phx.gbl...
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