🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1640

Re: TIdTCPServer and TIdTCPClient

#1640
From: Remy Lebeau (TeamB)
Date: Wed, 13 Dec 2006 00:20
26 lines
2119 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message
news:457f3780$1@newsgroups.borland.com...

> when the Client send a command with SendCmd, function doesn't return
> untill Reply and Response; the receiving thread I coded will steal the
Reply
> and the Response that SendCmd is waiting for?

Yes, it can (and vice versa, SendCmd() can steal data that the thread may be
waiting on).  Which is why you can't use SendCmd() anymore if you are using
a reading thread.  You will have to use WriteLn() instead, and then do all
of your reply processing inside of the thread as well.  So you are going to
have to design your data protocol in such as way that the thread will be
able to tell which packets are command replies and which ones are not.

One way around that is to wrap the connection in a critical section.  Then
you can "lock" the connection before calling SendCmd() and "unlock" it
afterwards.  Then the thread will not be able to read from the socket while
it is busy waiting for a command reply.

Othrwise, you will just have to go back to using a Timer again and forget
the thread altogether.


Gambit
Technical Details
Message-ID: <457f47cc$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <457dfd00$1@newsgroups.borland.com> <457e38a7$3@newsgroups.borland.com> <457f3780$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ca59e93c485c82fe
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <457dfd00$1@newsgroups.borland.com> <457e38a7$3@newsgroups.borland.com> <457f3780$1@newsgroups.borland.com>
Subject: Re: TIdTCPServer and TIdTCPClient
Date: Tue, 12 Dec 2006 16:20:47 -0800
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <457f47cc$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1165969356 75.83.34.171 (12 Dec 2006 16:22:36 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail