Re: Multithread safety
- From: "Alun Jones" <alun@xxxxxxxxxxxxx>
- Date: Mon, 14 Nov 2005 20:00:00 -0800
Eugene Gershnik wrote:
> Nathan Evans wrote:
>> You got me quite worried then :-)
>
> Well given m's point and thinking some more I will have to go back to my
> original statement. You must synchronize calls to WSARecv in one way or
> another. Otherwise it is impossible to correctly reassemble read results
> after completion notification. Same story (streams are not thread safe)
> but with a different twist.
Sort of.
If your protocol is TCP, then yes, you need to reassemble the read results.
If your protocol is UDP, then it depends on the protocol at the next layer
up, as to whether you need to assemble anything.
TCP is, by its nature, a serial protocol per-socket - as such, it makes very
little sense to consider multiple threads reading from the same socket at
the same time. Multiple threads writing to the same socket - now that is
something that might make sense, but there are some caveats there. You
should generally use a mutex to prevent two writes on the same socket from
interfering.
This is true even for an overlapped socket, because the WSASend() calls
might find their data is interleaved.
I know, not what you wanted to hear - you wanted to hear that Microsoft had
done this work for you. Sadly, no.
Alun.
~~~~
[Please don't email posters, if a Usenet response is appropriate.]
--
Texas Imperial Software | Find us at http://www.wftpd.com or email
23921 57th Ave SE | alun@xxxxxxxxxx
Washington WA 98072-8661 | WFTPD, WFTPD Pro are Windows FTP servers.
Fax/Voice +1(425)807-1787 | Try our NEW client software, WFTPD Explorer.
.
- Follow-Ups:
- Re: Multithread safety
- From: Eugene Gershnik
- Re: Multithread safety
- References:
- Multithread safety
- From: Mike Gleason Jr Couturier
- Re: Multithread safety
- From: Eugene Gershnik
- Re: Multithread safety
- From: Nathan Evans
- Re: Multithread safety
- From: Eugene Gershnik
- Re: Multithread safety
- From: Nathan Evans
- Re: Multithread safety
- From: Eugene Gershnik
- Re: Multithread safety
- From: Eugene Gershnik
- Re: Multithread safety
- From: Nathan Evans
- Re: Multithread safety
- From: Eugene Gershnik
- Multithread safety
- Prev by Date: Re: Changing TTL of incoming packets?
- Next by Date: Re: Changing TTL of incoming packets?
- Previous by thread: Re: Multithread safety
- Next by thread: Re: Multithread safety
- Index(es):
Relevant Pages
|