Re: Multithread safety
- From: "Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx>
- Date: Fri, 4 Nov 2005 22:22:02 +0200
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
>
>
.
- Follow-Ups:
- Re: Multithread safety
- From: Mike Gleason Jr Couturier
- Re: Multithread safety
- From: Mike Gleason Jr Couturier
- Re: Multithread safety
- References:
- Multithread safety
- From: Mike Gleason Jr Couturier
- Re: Multithread safety
- From: Eugene Gershnik
- Multithread safety
- Prev by Date: Re: Multithread safety
- Next by Date: Re: Multithread safety
- Previous by thread: Re: Multithread safety
- Next by thread: Re: Multithread safety
- Index(es):
Relevant Pages
|