🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

TServerSocket and Windows Services

#3853
From: Naresh Chandran
Date: Tue, 07 Jun 2005 19:44
44 lines
2825 bytes
Hi,

I have an application that uses TServerSocket. The TServerSocket is created
dynamically, and the connect, disconnect and read methods are attached to
__published methods of a TDataModule object, at runtime.

This works fine when run interactively: I have a form with a button, whose
onclick calls a global method (startServer) which creates the TServerSocket
dynamically (maintained in a global TServerSocket*, after being created by
new
TServerSocket(NULL)), assigns the serverType (non-blocking) and the event
handlers, and opens the socket (->Open()). Once the server is thus started,
the
functionality in the OnClientRead method is available to TCP clients
connecting/communicating with the server, and all three events, namely
OnClientConnect,  OnClientDisconnect and OnClientRead write to the log file.

Currently, I am trying to convert this application into a Windows Service.
In
this case, I do not create the form with the button on it, and instead
create
only the TDataModule with the event handlers, and on service startup, call
the
global method (startServer) that sets the server listening. I can see that
the
server is listening on the specified port through netstat, once I start the
service; But apparently, none of the TServerSocket events are triggered when
a
client connects, writes to the connection or disconnects, since none of the
log file entries expected from these methods are writte to the file. From
the client end,
it is possible to establish a connection, write to it and close it; but when
an
attempt is made to read, the client hangs up, and does not return until the
service is stopped, at which time the TServerSocket->Close() is called and
the
server is stopped.

Is there any reason for VCL component events to not fire when run as a
windows
service ?

Thanks,
Naresh.
Technical Details
Message-ID: <42a5f86a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news.maxwell.syr.edu!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b2d9cba8cb83bb9c,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Naresh Chandran" <naresh@sentori.com>
From: "Naresh Chandran" <naresh@sentori.com>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: TServerSocket and Windows Services
Date: Tue, 7 Jun 2005 15:44:57 -0400
Lines: 46
Organization: Sentori Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 65.120.70.75
Message-ID: <42a5f86a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1118173290 65.120.70.75 (7 Jun 2005 12:41:30 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!news.maxwell.syr.edu!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail