Re: Multithread safety

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Just as additional comment because Eugene didn't stress that , you don't
need two connections but one because socket connection is full duplex.
That even demand in security context because the less socket connections you
have in the system the less options for its hacking
Arkady

"Eugene Gershnik" <gershnik@xxxxxxxxxxx> wrote in message
news:u302DmX4FHA.1188@xxxxxxxxxxxxxxxxxxxxxxx
> Mike Gleason Jr Couturier wrote:
>> I know one can open 2 connections to do a
>> simultaneous 2 way connection...
>>
>> My question is can one thread exclusively read
>> on a socket while another exclusively write on it...
>
> Not sure what you mean by exclusively but yes you can read and write
> simultaneously.
> When discussing multi-threading it is important to first determine what is
> a shared "resource" that you are accessing. In case of a TCP socket there
> are 3 of them
>
> 1. The socket object itself
> 2. The input TCP stream
> 3. The output TCP stream.
>
> The socket object is thread safe. When you call recv() and send()
> simultaneously nothing in the socket internal data structures will break.
> The streams are separate resources so again recv() on one and send() on
> another are ok.
> What is usually not ok is two simultaneous recv()-s or send()-s. They
> access the same stream object and any stream is not safe for multiple
> reads or writes.
>
>
> --
> Eugene
> http://www.gershnik.com
>
>


.



Relevant Pages

  • Asynchronous Socket Server data
    ... The socket server knows what type of data it expects due to the interface ... I can have 1 databuffer only for each datatype to handle multiple connections? ... int bytesRead = handler.EndReceive; ... packetIndex, bytesRead); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Ping =?ISO-8859-1?Q?kr=E1ft=E9=E9_=3F_Advice_needed_?= =?ISO-8859-1?Q?to_trace_w
    ... He has two telephone extensions leading from the master socket and his ... presume that there is a fault in his extension wiring. ... If it's twisted pair ensure that it's not been connected split pair, in other words the blue white with white blue, orange white with white orange, if you get my drift, & the connections you should use are 2&5 ...
    (uk.telecom.broadband)
  • Re: !EventConnect Problem
    ... the June roll-up is available somewhere, although there's not been the usual ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)
  • Re: Multithread safety
    ... > on a socket while another exclusively write on it... ... The output TCP stream. ... The socket object is thread safe. ...
    (microsoft.public.win32.programmer.networks)
  • Re: !EventConnect Problem
    ... the June roll-up is available somewhere, ... The socket is not in a listening state. ... The incoming connection queue has no room for connections. ...
    (microsoft.public.windowsce.app.development)