Re: Socket Send and Receive Thread Safety

From: Ivar (ivx_at_lumisoft.ee)
Date: 02/21/05


Date: Mon, 21 Feb 2005 20:16:48 +0200


Hi,

Just think about it:
You can do it, it's not leagal but how you gurantee that data is sent to
socket in right order ?

For example:

you need to send:
    aaaaaa
    bbbbb

You call aaaaaa from 1 thread and bbbbbb on another:
what may happen:
    aaaaaa
    bbbbb
----- all as you excpect

    bbbbb
    aaaaa
This may happen if bbbbb thread finishes first.

For recieve, you never can be sure what is recieved by one thread and
another.
    may happen following situation:
        aaaaabbb
        bbbb

"Nizar" <Nizar@discussions.microsoft.com> wrote in message
news:E365972C-6186-4705-A734-E285B073FE30@microsoft.com...
> Is it safe for one thread to call Socket.Receive and another to call
> Socket.Send on the same Socket at the same time?
>
> 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.



Relevant Pages

  • Re: Socket Send and Receive Thread Safety
    ... > Is it okay to be sending data over a Socket at the same time as data is ... Is this okay or not? ... it's not leagal but how you gurantee that data is sent to ... >> For recieve, you never can be sure what is recieved by one thread and ...
    (microsoft.public.dotnet.framework)
  • Re: Socket Send and Receive Thread Safety
    ... Is it okay to be sending data over a Socket at the same time as data is ... > For recieve, you never can be sure what is recieved by one thread and ... >> safe, but I'm not sure whether this combination is or not. ...
    (microsoft.public.dotnet.framework)
  • Re: receiving data over socket
    ... I want to print the data the server received. ... anyone can recommend a good VB2005 book that deals with socket programming I ... if your server needs to support multiple connections ... You aren't guarenteed to recieve all your data ...
    (microsoft.public.dotnet.languages.vb)
  • Re: [OT] how to clean grime off old computer MB?
    ... I don't want to remove e.g. the CPU from its socket. ... You need to remove all socketed devices, and especially the CPU. ... which presumably is safe for the ... believe was safe for aluminum electrolytics; ...
    (Debian-User)
  • Re: Read from and Write to the same socket from two threads
    ... The FAQ page means the following: ... Anecdotal evidence suggests that one thread calling sendand another thread calling recvon a single socket is safe on recent Microsoft stacks at least. ...
    (microsoft.public.win32.programmer.networks)