Article View: borland.public.cppbuilder.internet.socket
Article #417Re: Using TIdTCPServer
From: Peter
Date: Fri, 01 Feb 2008 14:32
Date: Fri, 01 Feb 2008 14:32
27 lines
2820 bytes
2820 bytes
>> why is onExecute handler being invoked twice on the same socket >> connection? > >Because it is supposed to. TIdTCPServer calls OnExecute in a continuous >loop for the lifetime of the connection. You have your OnExecute code set >up to read a single command and then exit. The server will loop around, >call OnExecute again, read the next command (waiting as needed, raising an >exception if error/disconnect occurs), exit, and repeat. This is the >preferred way to use TIdTCPServer, so you are fine. > > >Gambit > > That's great info! Since, the "commands" in my case come from this old and not very well documented system, I figured I only get to the end of OnExecute handler, when the connection is closed by the host/client. It is evidently not so. So, what I did, is I added: AContext->Connection->Disconnect(); at the very end of the handler to make sure that the connection is dropped after servicing it's content. However, I see that sometimes it does not cause the OnDisconnect handler to fire, and the server does not accept any more connections after that (almost like it does not yeld to the main thread). Is there any additional handling that must be done to any of the components (AContext, or IOHandler)? P.S. I would love to post the full source, but I would have to provide the insides on how the ImagePlus sends its data, which is no fun :-) Thanks!
Technical Details
Message-ID:
<47a33b83$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<478e1c34$1@newsgroups.borland.com> <478e4760@newsgroups.borland.com> <4798a5e1$1@newsgroups.borland.com> <4798cf30$1@newsgroups.borland.com> <4798db8f$1@newsgroups.borland.com> <4798ef34$2@newsgroups.borland.com> <479e2c75$1@newsgroups.borland.com> <479e382e$1@newsgroups.borland.com> <479f4835$1@newsgroups.borland.com> <479f51f8$1@newsgroups.borland.com> <479f68b1$1@newsgroups.borland.com> <479f7070$1@newsgroups.borland.com> <479f9ae1$1@newsgroups.borland.com> <47a2265f$1@newsgroups.borland.com> <47a24592@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,452e664b18b0b56c X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Peter" <piotrtrzeciak@yahoo.com> Sender: "Peter" <piotrtrzeciak@yahoo.com> Reply-To: "Peter" <piotrtrzeciak@yahoo.com> Subject: Re: Using TIdTCPServer Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 207.45.45.41 References: <478e1c34$1@newsgroups.borland.com> <478e4760@newsgroups.borland.com> <4798a5e1$1@newsgroups.borland.com> <4798cf30$1@newsgroups.borland.com> <4798db8f$1@newsgroups.borland.com> <4798ef34$2@newsgroups.borland.com> <479e2c75$1@newsgroups.borland.com> <479e382e$1@newsgroups.borland.com> <479f4835$1@newsgroups.borland.com> <479f51f8$1@newsgroups.borland.com> <479f68b1$1@newsgroups.borland.com> <479f7070$1@newsgroups.borland.com> <479f9ae1$1@newsgroups.borland.com> <47a2265f$1@newsgroups.borland.com> <47a24592@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <47a33b83$1@newsgroups.borland.com> Date: 1 Feb 2008 07:32:19 -0700 X-Trace: newsgroups.borland.com 1201879939 207.105.83.66 (1 Feb 2008 07:32:19 -0700) Lines: 27 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail