🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Using TIdTCPServer

#576
From: Remy Lebeau (TeamB)
Date: Mon, 28 Jan 2008 20:17
51 lines
2812 bytes
"Peter" <piotrtrzeciak@yahoo.com> wrote in message 
news:479e2c75$1@newsgroups.borland.com...

> The main server (TIdTCPServer) component is part of the TService
> application, and in it's main Execute thread, it is started like this:
<snip>

Get rid of that OnExecute handler altogether.  TService already runs such a 
loop internally for you when no OnExecute handler is assigned.  Instead, 
activate the server in the OnStart event, and deactivate it in the service's 
OnStop/Shutdown events, ie:

    void __fastcall TMyService::ServiceStart(TObject *Sender, bool &Started)
    {
        iln_rcv_socket->Active = true;
        Started = true;
    }

    void __fastcall TMyService::ServiceStop(TObject *Sender, bool &Stopped)
    {
        ServiceShutdown(Sender);
        Stopped = true;
    }

    void __fastcall TMyService::ServiceShutdown(TObject *Sender)
    {
        iln_rcv_socket->Active = false;
    }


> This seems to be working ok, however, it appears that I can only
> get the first connection to come in ok, and the rest after that fail.

TIdTCPServer works fine in a service environment.  If you are having 
problems with connections, then your TIdTCPServer event handler code is 
likely buggy to begin with.

> I also added TIdAntiFreeze component to the TService application

TIdAntiFreeze is useless in a service.  It operates only in the context of 
the main thread, and acts as a no-op in worker threads.  TService does not 
run in the main thread.

> Also, I assume that all storage in OnExecute handler of the TIdTCPServer
> is local to the each thread.

What "storage" are you referring to exactly?


Gambit 
Technical Details
Message-ID: <479e382e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
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>

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: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
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>
Subject: Re: Using TIdTCPServer
Date: Mon, 28 Jan 2008 12:17:35 -0800
Lines: 53
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
NNTP-Posting-Host: 207.178.157.90
Message-ID: <479e382e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1201551406 207.178.157.90 (28 Jan 2008 12:16:46 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail