Article View: borland.public.cppbuilder.internet.socket
Article #1048Indy 10 application design
From: Old Wolf
Date: Mon, 11 Jun 2007 03:01
Date: Mon, 11 Jun 2007 03:01
26 lines
1844 bytes
1844 bytes
I am using Indy 10 that came with BDS2006, in C++. My questions are about how to manage threads with the Indy blocking sockets (previously I have only ever used sockets in asynchronous mode with select()). My application accepts multiple connections on a TIdTCPServer and re-routes them all on the same TIdTCPClient connection, then listens for responses and sends them back to where the initial request came from. 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? 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.
Technical Details
Message-ID:
<466cbb16$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5214d7fac32891ae,start X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Old Wolf" <oldwolf@inspire.net.nz> Sender: "Old Wolf" <oldwolf@inspire.net.nz> Reply-To: "Old Wolf" <oldwolf@inspire.net.nz> Subject: Indy 10 application design Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 202.27.210.143 NNTP-Posting-Host: 207.105.83.66 Message-ID: <466cbb16$1@newsgroups.borland.com> Date: 10 Jun 2007 20:01:42 -0700 X-Trace: newsgroups.borland.com 1181530902 207.105.83.66 (10 Jun 2007 20:01:42 -0700) Lines: 28 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail