🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14374

Re: TThreads & winapi critical section calls

#14374
From: Remy Lebeau (TeamB)
Date: Mon, 18 Aug 2003 19:16
32 lines
2481 bytes
"CC" <Xcurtc@tmscorp.com> wrote in message
news:3f411eb3$1@newsgroups.borland.com...

> The thread does standard C library open(),close(),access(),read(),write()
> calls only on file descriptors that it opened (for files), and
send(),recv()
> calls only on the socket descriptor it was passed. (The reason for using
> standard libary calls is that I'm using code portable with unix)

It doesn't matter which functions are you are using.  If you are accessing
the same file from different threads at the same time without proper
synchronizing, you are potentially setting your up for corrupting the file,
or your memory buffers, etc.

> Should send() and recv() be thread safe also? I couldn't imagine them not
> being.

You can safely read and write to a socket across threads, as long as one
thread is reading and other is writing.  However, if both threads are trying
to read from the socket, or both threads are trying to write to the socket,
then you are going to corrupt your data buffers on reading and your data
stream on writing.


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/03
Technical Details
Message-ID: <3f41247d$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!205.215.62.125.MISMATCH!in.100proofnews.com!in.100proofnews.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f3d5dfa$1@newsgroups.borland.com> <3f3d64aa$2@newsgroups.borland.com> <3f3d7670@newsgroups.borland.com> <3f3d9f65$1@newsgroups.borland.com> <3f411eb3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,455292b256c8f5c8
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-18 12:12:08 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f3d5dfa$1@newsgroups.borland.com> <3f3d64aa$2@newsgroups.borland.com> <3f3d7670@newsgroups.borland.com> <3f3d9f65$1@newsgroups.borland.com> <3f411eb3$1@newsgroups.borland.com>
Subject: Re: TThreads & winapi critical section calls
Date: Mon, 18 Aug 2003 12:16:36 -0700
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3f41247d$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1061233789 207.175.226.26 (18 Aug 2003 12:09:49 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!205.215.62.125.MISMATCH!in.100proofnews.com!in.100proofnews.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail