Article View: borland.public.cppbuilder.internet.socket
Article #5652Re: TIdTCPServer (Indy) problems
From: Remy Lebeau (TeamB)
Date: Wed, 30 Jun 2004 17:24
Date: Wed, 30 Jun 2004 17:24
57 lines
2647 bytes
2647 bytes
"Michele Santucci" <michele.santucci.nospam@nospam.celinavio.it> wrote in
message news:40e2baf1@newsgroups.borland.com...
> I need to write a server that's capable of accepting
> just one connection
Use TIdSimpleServer instead of TIdTCPServer. TIdSimpleServer is a
simplified TIdTCPServer specifically designed to handle a single connection
at a time.
> My first doubt is about the OnExchange event ..
There is no OnExchange event in Indy. Perhaps you mean OnExecute?
> is it triggered just when the server spawn for the first time
> the peer thread or each time something happens to the peer
> connection (read data, write data, disconnection)?
Assuming you do mean OnExecute, then it is triggered in a loop for the
lifetime of the connection regardless of what is actually happening on the
socket. It is the inner body of a "while not Terminated" loop for
TThread.Execute(), ie:
procedure TIdThread.Execute;
begin
//...
while not Terminated do begin
//...
BeforeRun;
while not Stopped do Run;
AfterRun;
end;
//...
end;
procedure TIdPeerThread.Run;
begin
//...
// triggers the TIdTCPServer.OnExecute event
Connection.Server.DoExecute(Self)
//...
end;
> Then.. what's the best way to handle safely peer's
> disconnections and server shutdowns?
All of that is already handled for you, as long as you are not doing your
own exception handling in the OnExecute event handler that prevents Indy
exceptions from reaching back to the TIdTCPServer for its own processing.
> I tried in several ways but I always have errors of all kinds.
Please be more specific.
Gambit
Technical Details
Message-ID:
<40e2f73f$3@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-mailReferences:
<40e2baf1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,598362c9168ae954 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <40e2baf1@newsgroups.borland.com> Subject: Re: TIdTCPServer (Indy) problems Date: Wed, 30 Jun 2004 10:24:18 -0700 Lines: 59 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: 68.169.168.124 Message-ID: <40e2f73f$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1088616255 68.169.168.124 (30 Jun 2004 10:24:15 -0700) 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