🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Closing TIDTCPServer

#5207
From: Alfred Thomas
Date: Fri, 01 Oct 2004 08:36
26 lines
1978 bytes
>Are you using TThread::Synchronize() or Post/SendMessage() with your client

Hi Remy 

No I am not. I created a small test application where I have a TIdTCPServer listening on a port and connecting to it with Telnet. When I set Active = false, the Telnet is not disconnected. In the actual program (windows service) , I have noticed that the server hangs when the client disconnected UN-gracefully and Active is set to true. The code looks like this:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
 IdTCPServer1->DefaultPort = 30011;
 IdTCPServer1->Active = true;
}
void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
{
 AnsiString Buffer = AThread->Connection->CurrentReadBuffer();
 if(!Buffer.IsEmpty()) Memo->Lines->Add(Buffer);
}
void __fastcall TForm1::Button3Click(TObject *Sender)
{
 IdTCPServer1->Active = false;
}

The reason I use CurrentReadBuffer() and not ReadLn is the data that needs to be read doesn't have specific terminating characters and I could get ReadLn to work on data without LF at the end.

Regards
Alfred
Technical Details
Message-ID: <415d16f4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <415c17fa$1@newsgroups.borland.com> <415c407e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ffbbfefff18a50d0
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alfred Thomas" <alfred@fischerint.co.za>
Sender: "Alfred Thomas" <alfred@fischerint.co.za>
Reply-To: "Alfred Thomas" <alfred@fischerint.co.za>
Subject: Re: Closing TIDTCPServer
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 196.25.217.126     
X-Forwarded-For: 192.96.150.202
References: <415c17fa$1@newsgroups.borland.com> <415c407e$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <415d16f4$1@newsgroups.borland.com>
Date: 1 Oct 2004 01:36:04 -0700
X-Trace: newsgroups.borland.com 1096619764 207.105.83.66 (1 Oct 2004 01:36:04 -0700)
Lines: 26
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail