Re: Events in a console app
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Sat, 26 Aug 2006 13:23:25 -0500
JamesR wrote:
I've tried using a TDataModule with a TServerSocket in a console app,
but for instance OnClientConnect never fires, although the client can
actually connect to the thread. I think it must work a differen't way
in console apps - no windows messages of course, so when I have my
console app waiting on a ReadLn() in the main program, perhaps no
events get fired.
Yep. Those events get fired in response to messages arriving at your program's window. But your program doesn't have a window, so no messages get handled.
Infact, i've also tried creating the TServerSocket in a TThread, which
again will allow a connection, but the events don't fire.
And again that's because there's nothing processing any messages.
Do I need to poll for these events. I would presume that TServerSocket
for example would have some internal notification of when the client
connects and call this event.
It does have an internal notification, but it relies on receiving a message from the OS. A message loop is fairly easy to write. The basic structure goes like this:
while GetMessage(...) > 0 do begin
TranslateMessage(...);
DispatchMessage(...);
end;
Look in MSDN for details on the parameters.
You might also consider using Indy, which does all its own listening and notification.
--
Rob
.
- Follow-Ups:
- Re: Events in a console app
- From: JamesR
- Re: Events in a console app
- References:
- Events in a console app
- From: JamesR
- Events in a console app
- Prev by Date: Events in a console app
- Next by Date: Re: Events in a console app
- Previous by thread: Events in a console app
- Next by thread: Re: Events in a console app
- Index(es):
Relevant Pages
|