Article View: borland.public.cppbuilder.internet.socket
Article #1052Re: Indy 10 application design
From: Remy Lebeau (TeamB)
Date: Mon, 11 Jun 2007 16:35
Date: Mon, 11 Jun 2007 16:35
32 lines
2316 bytes
2316 bytes
"Old Wolf" <oldwolf@inspire.net.nz> wrote in message news:466cbb16$1@newsgroups.borland.com... > I have managed to write an OnExecute handler for the > TIdTCPServer so that inbound packets can be read, and then > call IdTCPClient1->Socket->Send to send it on upstream. Is > IdTCPClient thread-safe or do I need some extra protection > in here? You need to serialize the writes yourself. > I have been able to read responses by setting up a TTimer > on the main form, and polling the IdTCPClient for incoming > messages. However I'm not sure if this is the recommended > strategy. Waiting for a blocking response in the same > function where I sent the message to the IdTCPClient will > not work because there I am in a thread of the Server, and > the message received might be the message intended for a > different thread. I would suggest using two dedicated threads with the TIdTCPClient. Have one thread contain a queue of outbound requests and continously sends thems them when available, and another thread that continuously reads the inbound responses that arrive. That way, when your TIdTCPServer receives a request, it can pass it on to the queue thread and then continue on with its own things, and then the response thread can pass the response back to the TIdTCPServer once it becomes available. Gambit
Technical Details
Message-ID:
<466d7a39@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<466cbb16$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5214d7fac32891ae X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <466cbb16$1@newsgroups.borland.com> Subject: Re: Indy 10 application design Date: Mon, 11 Jun 2007 09:35:38 -0700 Lines: 34 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.82.252.126 Message-ID: <466d7a39@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1181579833 75.82.252.126 (11 Jun 2007 09:37:13 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail