Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Wilfried Mestdagh
Hello Paul,

 Isn't there anyway to get the threadid of the service application ?

   Service.ServiceThread.ThreadID;

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Paul


 The standard Borland service unit runs a perfectly normal application
 message pump, and you can drop event drive components like ICS, timers,
 etc, onto the form and they just work, and you can post message to the
 form handle.

How to post the message to what handle.
If you create a new service application, you can drop non-UI components on 
it.
I have tried posting a message (postmessage/ postThreadMessage) to the 
Service handle and servive threadid, but none of them seem to work
Am I missing something here ?

Paul


Main Service application unit :

type
  TRPPollSvc = class(TService)
procedure ServiceExecute(Sender: TService);
procedure ServiceStart(Sender: TService; var Started: boolean);
procedure ServiceStop(Sender: TService; var Stopped: boolean);
procedure ServiceDestroy(Sender: TObject);
procedure ServiceCreate(Sender: TObject);
procedure WMError(var message: TMessage); message WM_ERROR;
  private
{ Private declarations }
PServer: TPSvc;
FLogfileName  : string;
FLogInitiated : boolean;
procedure Display(Msg: string);
  public
function GetServiceController: TServiceController; override;
{ Public declarations }
  end;

var
  RPPollSvc: TRPPollSvc;

implementation

{$R *.DFM}

procedure ServiceController(CtrlCode: DWord); stdcall;
begin
  RemotePassPollSvc.Controller(CtrlCode);
end;

function TRPPollSvc.GetServiceController: TServiceController;
begin
  Result := ServiceController;
end;

procedure TRPPollSvc.ServiceExecute(Sender: TService);
begin
  while not terminated do ServiceThread.ProcessRequests(true);
end;

procedure TRPPollSvc.ServiceStart(Sender: TService; var Started: boolean);
begin
  // give handle to server object - it needs it to post a message to the 
service application
  PServer.MainHandle:= ServiceThread.ThreadID;// .Handle;
  if PServer.StartServer then Started:= true
else Started:= false;
end;

procedure TRPPollSvc.ServiceStop(Sender: TService; var Stopped: boolean);
begin
  PServer.StopServer;
  Stopped:= true;
end;

procedure TRPPollSvc.ServiceDestroy(Sender: TObject);
begin
  if Assigned(PServer) then
begin
  PServer.Free;
  PServer:= nil;
end;
end;

procedure TRPPollSvc.ServiceCreate(Sender: TObject);
begin
  PServer:= TPSvc.Create;
  PServer.OnDisplay:= Display;
  FLogFileName:= ChangeFileExt(Application.ExeName, '.log');
end;

procedure TRPPollSvc.Display(Msg: string);
var
  lFile: TextFile;
begin
  AssignFile(lFile, FLogFileName);
  try
try
  if not FileExists(FLogFileName) then ReWrite(lFile)
  else Append(lFile);
  if not FLogInitiated then  //just opened
begin
  FLogInitiated:= true;
  WriteLn(lFile, Msg);
end;
  Writeln(lFile, Msg);
finally
  CloseFile(lFile);
end;
  except
  end;
end;

procedure TRPPollSvc.WMError(var message: TMessage); //message WM_ERROR;
begin
  Display('Error');
end;

end.


From a thread within the server object I've tried to post a message to the 
service handle/threadID
PostThreadMessage(MainHandle, WM_ERROR, 0, 0);


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] HTTPCli in multithreaded application

2006-04-12 Thread Albjan
Hello,

Just finished a application that creates a HTTPCli object dynamically in
threads.
Some 100 Pc's needs to be ping (network performance) and then 5 different
httpcli-head actions on that Pc (wifi proxy testing).  
The only way it works without memory losses (with BCB6.0) is to use it ASYNC
in the thread.
The HTTPCli object can be used for more than one request.
Multithreaded doesn't matter.

Regards Albert

  

 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] Namens Wilfred Owen
 Verzonden: maandag 10 april 2006 11:10
 Aan: twsocket@elists.org
 Onderwerp: [twsocket] HTTPCli in multithreaded application
 
 Hello
 
 I am new to ICS. I wish to use the HTTPCli component in a 
 multithreaded application to test the response from websites. 
 Any thread within the application may use an HTTPCli object 
 to make such a test.
 
 My preferred approach would be: within a thread, create an 
 HTTPCli object dynamically using the create method, and set 
 the URL property. Then set handlers for onDocData, and 
 onRequestDone and retrieve the page using the
 Get() function. Use an exception handler to trap any problem 
 with Get().
 
 - Do you see any potential problems with this, given that it 
 will occur in a multithreaded environment?
 - Are there any problems with having multiple HTTPCli objects 
 running in multiple threads as described?
 - Also, do I need to set the multithreaded property to true?
 
 Thank you in advance for any assistance you can give.
 
 Wilf
 
 
 --
 To unsubscribe or change your settings for TWSocket mailing 
 list please goto http://www.elists.org/mailman/listinfo/twsocket
 Visit our website at http://www.overbyte.be
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Angus Robertson - Magenta Systems Ltd
From a thread within the server object I've tried to post a message 
to the service handle/threadID
 procedure TRPPollSvc.WMError(var message: TMessage); //message 
 WM_ERROR;
PostThreadMessage(MainHandle, WM_ERROR, 0, 0);

It should be: 

PostMessage (RPPollSvc.Handle, WM_ERROR, 0, 0);

which is the context in which the application is running and in which 
you are listening for the message.  

But looking at my own code, I don't seem to sending any private messages 
in my one historic service, all my recent (five years) service 
applications have been dual purpose service/interactive.  

Angus
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Paul
Hi Angus,

That's was my first impression also, however RPPollSvc.Handle doesn't exist 
:-(


Paul

 It should be:

 PostMessage (RPPollSvc.Handle, WM_ERROR, 0, 0);



-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Wilfried Mestdagh
Hello Paul,

 That's was my first impression also, however RPPollSvc.Handle doesn't exist
 :-(

Correct. TService is derrived from TDataModule and has no windows
handle. However you can make one with AllocateHWND.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] HTTPCli in multithreaded application

2006-04-12 Thread Wilfred Owen
Thanks Abjan and Arno for your suggestions. I will be reading those 
articles. At the moment I have set up a test brace with a thread/message 
pump, and it is working well. I may have more questions as I try more things 
out, but it looks good so far.

Thanks again for you help - I'm very impressed with this mailing list!

Wilf


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Arno Garrels
Wilfried Mestdagh wrote:
 Hello Paul,
 
 That's was my first impression also, however RPPollSvc.Handle doesn't
 exist :-(
 
 Correct. TService is derrived from TDataModule and has no windows
 handle. However you can make one with AllocateHWND.

That's probably the best way. 

If you need to receive custom messages in ServiceThread's pump, why? 
you could do something like this: 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;

type
  TService1 = class(TService)
procedure ServiceExecute(Sender: TService);
  protected
function DoCustomControl(CtrlCode: DWord): Boolean; override;  
  private
{ Private-Deklarationen }
  public
function GetServiceController: TServiceController; override;
{ Public-Deklarationen }
  end;

var
  Service1: TService1;

implementation

{$R *.DFM}

procedure ServiceController(CtrlCode: DWord); stdcall;
begin
  Service1.Controller(CtrlCode);
end;

function TService1.DoCustomControl(CtrlCode: DWord): Boolean;
begin
if CtrlCode = 256 then
beep
end;

function TService1.GetServiceController: TServiceController;
begin
  Result := ServiceController;
end;

procedure TService1.ServiceExecute(Sender: TService);
begin
while not terminated do
begin
ServiceThread.ProcessRequests(False);
PostThreadMessage(ServiceThread.ThreadID, CM_SERVICE_CONTROL_CODE, 256, 
0);
sleep(500);
end;
end; 

I think CtrlCode 128..255 is reserved.


---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Paul


 Wilfried Mestdagh wrote:
 Hello Paul,

 That's was my first impression also, however RPPollSvc.Handle doesn't
 exist :-(

 Correct. TService is derrived from TDataModule and has no windows
 handle. However you can make one with AllocateHWND.


Thanks Wilfried, got it working with this way :-)


 If you need to receive custom messages in ServiceThread's pump, why?

Have a Http server with 12 threads for various processing and database 
operations.
These threads work completelely independent from the servers operations and 
they get their orders from the server thru a queue (with a CS ).
This works fast (there are no delays, except for the critical section).
I want to inform the server whewnever an error occurs in one of the threads 
without the use of sync objects (delays !).
So posting a message is the fastest way.


Paul





-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Angus Robertson - Magenta Systems Ltd
  That's was my first impression also, however RPPollSvc.Handle 
  doesn't exist
  :-(
 
 Correct. TService is derrived from TDataModule and has no windows
 handle. However you can make one with AllocateHWND.

I guess message problems may have been why I gave up using the Borland 
service environment.  

Except for my latest service using Wilfred's unit (that links both 
environments in the same program), I've been using a simple service 
starter that runs a normal GUI application, and sends it a stop message 
when the service is requested to stop.  This all makes debugging 
trivial.  

Angus
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Postmessage in Service application

2006-04-12 Thread Arno Garrels
Paul wrote:
 Wilfried Mestdagh wrote:
 Hello Paul,
 
 That's was my first impression also, however RPPollSvc.Handle doesn't
 exist :-(
 
 Correct. TService is derrived from TDataModule and has no windows
 handle. However you can make one with AllocateHWND.
 
 
 Thanks Wilfried, got it working with this way :-)
 
 
 If you need to receive custom messages in ServiceThread's pump, why?
 
 Have a Http server with 12 threads for various processing and database
 operations.
 These threads work completelely independent from the servers operations
 and they get their orders from the server thru a queue (with a CS ).
 This works fast (there are no delays, except for the critical section).
 I want to inform the server whewnever an error occurs in one of the
 threads without the use of sync objects (delays !).
 So posting a message is the fastest way.

Yes I also use messages where I can, for logging across thread boarders etc., 
however with using DoCustomControl you don't need another window.
Was just another idea... 

Arno

 
 
 Paul
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] NOFORMS with ICS v5 TTnCnx class

2006-04-12 Thread Bevan Edwards
Hi all,

I was compiling ICS v5 with NOFORMS defined and found that the TTnCnx 
class is not properly setup for this - it uses WSocket.AllocateHWND and 
WSocket.DeallocateHWnd.  I have corrected it by copying the appropriate 
code from another component, but thought that Francois my like to fix 
the original source files.

Regards,

Bevan


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NOFORMS with ICS v5 TTnCnx class

2006-04-12 Thread Francois PIETTE
 I was compiling ICS v5 with NOFORMS defined and found that the TTnCnx
 class is not properly setup for this - it uses WSocket.AllocateHWND and
 WSocket.DeallocateHWnd.  I have corrected it by copying the appropriate
 code from another component, but thought that Francois my like to fix
 the original source files.

It will be faster that you email your updated file since you seems to have 
done the work !

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NOFORMS with ICS v5 TTnCnx class

2006-04-12 Thread Bevan Edwards
Hi Francois,

I have sent the file directly to your e-mail address, rather than the list.

Regards,

Bevan


Francois PIETTE wrote:
I was compiling ICS v5 with NOFORMS defined and found that the TTnCnx
class is not properly setup for this - it uses WSocket.AllocateHWND and
WSocket.DeallocateHWnd.  I have corrected it by copying the appropriate
code from another component, but thought that Francois my like to fix
the original source files.
 
 
 It will be faster that you email your updated file since you seems to have 
 done the work !
 
 --
 Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
 --
 [EMAIL PROTECTED]
 http://www.overbyte.be
 
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] Compiling ICSBCB100 project for ICS v5

2006-04-12 Thread Bevan Edwards
Hi all,

As someone earlier indicated, I built the ICSDel100 project and then 
turned on Generate All C++Builder files option, which seems to have 
worked alright.

However, if I try to build the ICSBCB100 project, it gives me errors 
about mssing .OBJ files.  The first is ICSLOGGER.OBJ, which I found in 
the output from the ICSDEL100 project, so I just used that.  But the 
next is ICMP.OBJ, which doesn't appear to be anywhere.

Has anyone had any success building this project?
Do we need to build this project?

Regards,

Bevan

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Compiling ICSBCB100 project for ICS v5

2006-04-12 Thread Francois PIETTE
 As someone earlier indicated, I built the ICSDel100 project and then
 turned on Generate All C++Builder files option, which seems to have
 worked alright.

 However, if I try to build the ICSBCB100 project, it gives me errors
 about mssing .OBJ files.  The first is ICSLOGGER.OBJ, which I found in
 the output from the ICSDEL100 project, so I just used that.  But the
 next is ICMP.OBJ, which doesn't appear to be anywhere.

The compiler should compile IcsLogger.pas and Icmp.pas (provided) to create 
the corresponding .obj files. I don't know why they are not compiled. Are 
the files listed in the project ?


--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NOFORMS with ICS v5 TTnCnx class

2006-04-12 Thread Francois PIETTE
 I have sent the file directly to your e-mail address, rather than the 
 list.

Looking at the change you've made, I see that you have not the latest ICS 
(beta) version. In the latest beta version, Arno Garrels already made those 
changes ! In the history, it is dated march 11th.

--
[EMAIL PROTECTED]
http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Compiling ICSBCB100 project for ICS v5

2006-04-12 Thread Arno Garrels
Bevan Edwards wrote:
 Hi all,
 
 As someone earlier indicated, I built the ICSDel100 project and then
 turned on Generate All C++Builder files option, which seems to have
 worked alright.
 
 However, if I try to build the ICSBCB100 project, it gives me errors
 about mssing .OBJ files.  The first is ICSLOGGER.OBJ, which I found in
 the output from the ICSDEL100 project, so I just used that.  But the
 next is ICMP.OBJ, which doesn't appear to be anywhere.
 
 Has anyone had any success building this project?
 Do we need to build this project?

AFAIK if you built the Delphi package with option Generate All C++Builder
files you should not try to build ICSBCB100 as well. Components will be
available on the palette in both BCB and Delphi personality as well. 
That's at least what I found thru trial and error. 


 
 Regards,
 
 Bevan
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Compiling ICSBCB100 project for ICS v5

2006-04-12 Thread Bevan Edwards
Hi Francois,

Francois PIETTE wrote:
As someone earlier indicated, I built the ICSDel100 project and then
turned on Generate All C++Builder files option, which seems to have
worked alright.

However, if I try to build the ICSBCB100 project, it gives me errors
about mssing .OBJ files.  The first is ICSLOGGER.OBJ, which I found in
the output from the ICSDEL100 project, so I just used that.  But the
next is ICMP.OBJ, which doesn't appear to be anywhere.
 
 
 The compiler should compile IcsLogger.pas and Icmp.pas (provided) to create 
 the corresponding .obj files. I don't know why they are not compiled. Are 
 the files listed in the project ?

No, neither of them are listed in the project.  But then I noticed that 
ICMP is not listed in the ICSDel100 project either.

Regards,

Bevan

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Compiling ICSBCB100 project for ICS v5

2006-04-12 Thread Bevan Edwards
Hi Arno,

As someone earlier indicated, I built the ICSDel100 project and then
turned on Generate All C++Builder files option, which seems to have
worked alright.

However, if I try to build the ICSBCB100 project, it gives me errors
about mssing .OBJ files.  The first is ICSLOGGER.OBJ, which I found in
the output from the ICSDEL100 project, so I just used that.  But the
next is ICMP.OBJ, which doesn't appear to be anywhere.

Has anyone had any success building this project?
Do we need to build this project?
 
 
 AFAIK if you built the Delphi package with option Generate All C++Builder
 files you should not try to build ICSBCB100 as well. Components will be
 available on the palette in both BCB and Delphi personality as well. 
 That's at least what I found thru trial and error. 

Yes, the components are available for C++Builder projects, so I'll just 
skip building the ICSBCB100 package.

The only problem I found was that the Generate All C++Builder files 
option didn't create the *.OBJ files, but Generate C++ object files 
did, so that's alright.

I usually build my applications with Packages and Dynamic RTL turned 
off, so that's why I needed the *.OBJ files.

Regards,

Bevan

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] NOFORMS with ICS v5 TTnCnx class

2006-04-12 Thread Bevan Edwards
Hi Francois,

Francois PIETTE wrote:
I have sent the file directly to your e-mail address, rather than the 
list.
 
 
 Looking at the change you've made, I see that you have not the latest ICS 
 (beta) version. In the latest beta version, Arno Garrels already made those 
 changes ! In the history, it is dated march 11th.

I downloaded and used the ICS v5 from your web site - that indicates 
that it's from 09/03/06.  Where I can download the most recent version from?

Regards,

Bevan

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be