I will revisit my code. I did write a visual app for testing purposes, which
uses most the same modules as the service app and works OK on the Win2003
SBS box. The code is also based on your echo example. There is not that much
difference between the two except there are no visual components in the
service app and I have used a datamodule for the code which is in unit1.
The DPR's look like.
{visual app}
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
ipcollex in 'ipcollex.pas',
DataParseThread in 'DataParseThread.pas',
DataCalculate in 'DataCalculate.pas';
{service app}
uses
SvcMgr,
CollexServiceUnit1 in 'CollexServiceUnit1.pas' {CallCollexDataCollectorV2:
TService},
CollexServiceUnit2 in 'CollexServiceUnit2.pas' {DataModule2: TDataModule},
ipcollex in 'ipcollex.pas',
DataParseThread in 'DataParseThread.pas',
DataCalculate in 'DataCalculate.pas';
I wonder if I need to do something else for a service?
=====================================================================
unit CollexServiceUnit1;
interface
uses
Sharemem, Windows, Messages, SysUtils, Classes, Graphics, Controls,
SvcMgr, Dialogs, CollexServiceUnit2;
type
TCallCollexDataCollectorV2 = class(TService)
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceCreate(Sender: TObject);
procedure ServiceDestroy(Sender: TObject);
private
{ Private declarations }
procedure Log(const msg: string);
public
FDataModule: TDataModule2;
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
var
CallCollexDataCollectorV2: TCallCollexDataCollectorV2;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
CallCollexDataCollectorV2.Controller(CtrlCode);
end;
function TCallCollexDataCollectorV2.GetServiceController:
TServiceController;
begin
Result := ServiceController;
end;
procedure TCallCollexDataCollectorV2.ServiceCreate(Sender: TObject);
begin
Log(Format('Create called from process %d thread %d',
[GetCurrentProcessID, GetCurrentThreadID]));
end;
procedure TCallCollexDataCollectorV2.ServiceDestroy(Sender: TObject);
begin
Log(Format('Destroy called from process %d thread %d',
[GetCurrentProcessID, GetCurrentThreadID]));
end;
procedure TCallCollexDataCollectorV2.ServiceStart(Sender: TService;
var Started: Boolean);
begin
Log(Format('Start called from process %d thread %d',
[GetCurrentProcessID, GetCurrentThreadID]));
FDataModule := TDataModule2.Create(nil);
Started := true;
end;
procedure TCallCollexDataCollectorV2.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
Log(Format('Stop called from process %d thread %d',
[GetCurrentProcessID, GetCurrentThreadID]));
FreeAndNil(FDataModule);
Stopped := true;
end;
procedure TCallCollexDataCollectorV2.Log(const msg: string);
var
fLog: textfile;
begin
AssignFile(fLog, 'c:\CallCollexService.log');
if FileExists('c:\CallCollexService.log') then
Append(fLog)
else
Rewrite(fLog);
Writeln(fLog, msg);
CloseFile(fLog);
end; { TService1.Log }
end.
----- Original Message -----
From: "Lukas Gebauer" <[EMAIL PROTECTED]>
To: "Ararat Synapse" <[email protected]>
Sent: Wednesday, January 17, 2007 12:37 PM
Subject: Re: [Synalist] Problem with windows 2003 SBS server
>> I am have a problem with a service app I wrote in delphi 2006 on
>> windows 2003 SBS server, which uses port 4515 to capture data, process
>> it and put it into a database. If I start the service all seems to be
>> OK until the app receives some data and after doing the first
>> iteration of processing the data, port 4515 is not available. If I
>> restart the service I can receive another set of data and then it
>> stops again. The strange thing is the app work's fine on Win2K, WinXP
>> and windows 2003 server.
>>
>> Is there anything special I need to do on windows 2003 (SBS) you may
>> be aware of?
>
> You must have bad your code. Are you using TCP? If yes, you have
> problem with listening socket vs. accepted socket. See for my demos
> for inspiration.
>
> --
> Lukas Gebauer.
>
> E-mail: [EMAIL PROTECTED]
> http://synapse.ararat.cz/ - Ararat Synapse - TCP/IP Lib.
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> synalist-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/synalist-public
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public