Re: Socket Send and Receive Thread Safety

From: Nizar (Nizar_at_discussions.microsoft.com)
Date: 02/21/05


Date: Mon, 21 Feb 2005 10:33:05 -0800

I'm not concerned about simultaneous sends or receives. Let me see if I can
explain it better:

Is it okay to be sending data over a Socket at the same time as data is
being received on it? For example, have one thread that only sends data and
another thread that only reads data without synchronizing access to the
shared Socket. So, one thread calls Socket.Receive at the same time as
another thread calls Socket.Send. Is this okay or not?

"Ivar" wrote:

>
> 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
    ... 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 ... > Socket.Send on the same Socket at the same time? ... > safe, but I'm not sure whether this combination is or not. ...
    (microsoft.public.dotnet.framework)
  • Re: Is it worth making an 8031/32 board?
    ... soldered to each one but leaving them free to socket up okay, ... sitting in a box -- from many years ...
    (comp.arch.embedded)
  • 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: OT:Wireless Network Problem
    ... between PC and modem/router is fine and Tiscali say the phone line is okay. ... Lights on the front of the router indicate there is no DSL signal so to me ... Can you test the socket, in case its a wiring fault on that socket? ...
    (uk.media.dvd)
  • Re: <string> class with support of Null-Bytes?
    ... Okay, this is my test program. ... string and then send this via using socket to/from server. ...
    (comp.lang.cpp)

Loading