Re: [twsocket] Use of twsocket in thttpserver application

2009-12-23 Thread Francois PIETTE

Hi Chris,


Thanks for all the help with my Twsocket problem.  You will be pleased to
know that I have deployed the solution and everything works perfectly.


Thank you for your positive feedback.
I'm always happy to receive messages saying everything is OK :-)



Have a great Christmas and a Happy New Year


Merry Christmas and Happy New Year to you and your family.
--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-23 Thread Chris Schofield
Hi everyone

Thanks for all the help with my Twsocket problem.  You will be pleased to
know that I have deployed the solution and everything works perfectly.

Have a great Christmas and a Happy New Year

Regards
Chris

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Francois PIETTE
Sent: 08 December 2009 17:03
To: ICS support mailing
Subject: Re: [twsocket] Use of twsocket in thttpserver application

Looks like you started to grasp async programming. Very good !
Don't forget you have to free the TWSocket at some time.
I think you still need a single TTimer to handle timeout. Think about what 
will happend if you start a connection successfully and then have a server 
not answering at all, but letting the connection opened. I guess you want to

break the connection to that server after some timeout.

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: "Chris Schofield" 
To: "'ICS support mailing'" 
Sent: Tuesday, December 08, 2009 1:35 PM
Subject: Re: [twsocket] Use of twsocket in thttpserver application


> Hi Angus (and all who have helped)
>
> I have created an array of (50) Twsockets.  I then choose a new one each
> time I need to connect as you suggested.
>
> It works perfectly. I don't need the timer anymore and have removed the
> application.processmessages.
>
> Everything seems perfect.  I need to give it a good testing now.
>
> Many thanks
>
> Chris
>
> -Original Message-
> From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
> Behalf Of Angus Robertson - Magenta Systems Ltd
> Sent: 08 December 2009 09:31
> To: twsocket@elists.org
> Subject: Re: [twsocket] Use of twsocket in thttpserver application
>
>> I am using application.processmessages because I need to connect to
>> several different sockets as follows
>
> Just create a dynamic array with one TWSocket for each connection, then
> start them all together.
>
> Application.ProcessMessages can be used in ICS client applications using
> the sync methods, but must never be used in ICS server applications which
> are purely async.
>
>> The connected event closes the connection.  My timer aborts the
>> connection if it takes too long.
>
> You only need a single timer that checks if the connections have
> completed, again an array of tickcounts when they started.  Not really
> necessary to abort them, since a connection should always time out
> eventually.  The ICS FTP server code does this to close idle clients.
>
> Angus
>
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be 

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

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-08 Thread Anton Sviridov
Hello Chris,
I've wrote simple descendant of TWSocket which implements timeout stuff 
internally, I could send you the unit if you are interested

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-08 Thread Francois PIETTE

Looks like you started to grasp async programming. Very good !
Don't forget you have to free the TWSocket at some time.
I think you still need a single TTimer to handle timeout. Think about what 
will happend if you start a connection successfully and then have a server 
not answering at all, but letting the connection opened. I guess you want to 
break the connection to that server after some timeout.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be


- Original Message - 
From: "Chris Schofield" 

To: "'ICS support mailing'" 
Sent: Tuesday, December 08, 2009 1:35 PM
Subject: Re: [twsocket] Use of twsocket in thttpserver application



Hi Angus (and all who have helped)

I have created an array of (50) Twsockets.  I then choose a new one each
time I need to connect as you suggested.

It works perfectly. I don't need the timer anymore and have removed the
application.processmessages.

Everything seems perfect.  I need to give it a good testing now.

Many thanks

Chris

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Angus Robertson - Magenta Systems Ltd
Sent: 08 December 2009 09:31
To: twsocket@elists.org
Subject: Re: [twsocket] Use of twsocket in thttpserver application


I am using application.processmessages because I need to connect to
several different sockets as follows


Just create a dynamic array with one TWSocket for each connection, then
start them all together.

Application.ProcessMessages can be used in ICS client applications using
the sync methods, but must never be used in ICS server applications which
are purely async.


The connected event closes the connection.  My timer aborts the
connection if it takes too long.


You only need a single timer that checks if the connections have
completed, again an array of tickcounts when they started.  Not really
necessary to abort them, since a connection should always time out
eventually.  The ICS FTP server code does this to close idle clients.

Angus

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

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


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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-08 Thread Chris Schofield
Hi Angus (and all who have helped)

I have created an array of (50) Twsockets.  I then choose a new one each
time I need to connect as you suggested.

It works perfectly. I don't need the timer anymore and have removed the
application.processmessages.

Everything seems perfect.  I need to give it a good testing now.

Many thanks

Chris

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Angus Robertson - Magenta Systems Ltd
Sent: 08 December 2009 09:31
To: twsocket@elists.org
Subject: Re: [twsocket] Use of twsocket in thttpserver application

> I am using application.processmessages because I need to connect to 
> several different sockets as follows

Just create a dynamic array with one TWSocket for each connection, then
start them all together.

Application.ProcessMessages can be used in ICS client applications using
the sync methods, but must never be used in ICS server applications which
are purely async.  

> The connected event closes the connection.  My timer aborts the 
> connection if it takes too long.

You only need a single timer that checks if the connections have
completed, again an array of tickcounts when they started.  Not really
necessary to abort them, since a connection should always time out
eventually.  The ICS FTP server code does this to close idle clients. 

Angus

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

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-08 Thread wilfried Mestdagh
Hi,

>while sckCustScreen.State <> wsclosed do
>  Application.ProcessMessages;

No, use the State property only for displaying states, not to take action.
Also it is not a wise idea to put your application in a loop. Use OnClose
event of the socket. It will fire when it is close; in the OnClose event you
can post a message to a custom message handler to reconnect again.

-- 
mvg, Wilfried
http://www.mestdagh.biz


-Oorspronkelijk bericht-
Van: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] Namens
Chris Schofield
Verzonden: dinsdag 8 december 2009 9:45
Aan: 'ICS support mailing'
Onderwerp: Re: [twsocket] Use of twsocket in thttpserver application

Hi 

Many thanks for all the replies. This is a really great mailing list

I am using application.processmessages because I need to connect to several
different sockets as follows

  for i := 1 to CustScreenCount do begin
while sckCustScreen.State <> wsclosed do
  Application.ProcessMessages;
sckCustScreen.Addr := HttpServer1.Addr;
sckCustScreen.Port := IntToStr(51000 + i);
try
  sckCustScreen.Tag := 1;
  timSocket.Enabled := True;
  sckCustScreen.Connect;
except
end;
  end;

The connected event closes the connection.  My timer aborts the connection
if it takes too long.

I have put a single twsocket on my form and I am trying to reuse it.
Everybody has told me that the application.processmessages is very bad.

Any ideas on the best way for my program to be coded to do what I want?

Regards
Chris

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Angus Robertson - Magenta Systems Ltd
Sent: 07 December 2009 15:46
To: twsocket@elists.org
Subject: Re: [twsocket] Use of twsocket in thttpserver application

> Each time my webserver needs to "nudge" one of the other 
> applications then I guess I should start a thread to do this.

Why do you need a thread?  If you call connect to open a socket to the
other application, it will eventually give a connect event with fail or
success, from which you can trigger some other action if necessary. 

Look in OverbyteIcsWebAppServerMailer.pas which uses illustrates sending
email from a web page, using a series of events.  

Angus

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

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

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-08 Thread Angus Robertson - Magenta Systems Ltd
> I am using application.processmessages because I need to connect to 
> several different sockets as follows

Just create a dynamic array with one TWSocket for each connection, then
start them all together.

Application.ProcessMessages can be used in ICS client applications using
the sync methods, but must never be used in ICS server applications which
are purely async.  

> The connected event closes the connection.  My timer aborts the 
> connection if it takes too long.

You only need a single timer that checks if the connections have
completed, again an array of tickcounts when they started.  Not really
necessary to abort them, since a connection should always time out
eventually.  The ICS FTP server code does this to close idle clients. 

Angus

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-08 Thread Chris Schofield
Hi 

Many thanks for all the replies. This is a really great mailing list

I am using application.processmessages because I need to connect to several
different sockets as follows

  for i := 1 to CustScreenCount do begin
while sckCustScreen.State <> wsclosed do
  Application.ProcessMessages;
sckCustScreen.Addr := HttpServer1.Addr;
sckCustScreen.Port := IntToStr(51000 + i);
try
  sckCustScreen.Tag := 1;
  timSocket.Enabled := True;
  sckCustScreen.Connect;
except
end;
  end;

The connected event closes the connection.  My timer aborts the connection
if it takes too long.

I have put a single twsocket on my form and I am trying to reuse it.
Everybody has told me that the application.processmessages is very bad.

Any ideas on the best way for my program to be coded to do what I want?

Regards
Chris

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Angus Robertson - Magenta Systems Ltd
Sent: 07 December 2009 15:46
To: twsocket@elists.org
Subject: Re: [twsocket] Use of twsocket in thttpserver application

> Each time my webserver needs to "nudge" one of the other 
> applications then I guess I should start a thread to do this.

Why do you need a thread?  If you call connect to open a socket to the
other application, it will eventually give a connect event with fail or
success, from which you can trigger some other action if necessary. 

Look in OverbyteIcsWebAppServerMailer.pas which uses illustrates sending
email from a web page, using a series of events.  

Angus

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

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Paul
Each time my webserver needs to "nudge" one of the other applications then 
I

guess I should start a thread to do this.


Not always, but when it has lenghty operations to perform.
Keep in mind that creating a thread takes its time too.
If you have to create a thread frequently, it's better to create a 
continuous thread and just add a new request to an input queue.
If you need resulting data from the thread, then you can create an output 
queue also (producer-consumer Q's).

This is an excellent way if time is critical.

Paul 


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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Francois PIETTE

After I call connect I call application processmessages until I get
connected and then I close.

Do you think this could be "interfering" with the HttpServer component
logic?


Not excatly the logic, but it will make things go wrong because calling 
ProcessMessages will cause events to be triggered then have the component 
reenter his event handler before the previous event is processed. That will 
not work !



Is doing the communication socket call in a separate thread better than in
the main thread?


No need for another thread. Just use asynchronous operation. From the server 
event, you may defer sending the reply to the client until you are done with 
what you have to do with the secondary connection. Just use hgSendMyself to 
make the server component happy. Later, in the event chain you'll trigger 
calling TWSocket, call one of the Answer methods to send the reply to the 
client.


You only need a thread when you have to do a lengthy operation such as 
computation or blocking SQL request.


--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Angus Robertson - Magenta Systems Ltd
> Each time my webserver needs to "nudge" one of the other 
> applications then I guess I should start a thread to do this.

Why do you need a thread?  If you call connect to open a socket to the
other application, it will eventually give a connect event with fail or
success, from which you can trigger some other action if necessary. 

Look in OverbyteIcsWebAppServerMailer.pas which uses illustrates sending
email from a web page, using a series of events.  

Angus

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Chris Schofield
Hi Paul

Hmm. I thought the application process messages might be screwing things up.
I just needed it confirming.

Each time my webserver needs to "nudge" one of the other applications then I
guess I should start a thread to do this.

The "other" applications simply come to life when "nudged" by the webserver
app.  The apps are on different systems hence the use
Of a socket to nudge it.


Regards
Chris


-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Paul
Sent: 07 December 2009 14:36
To: ICS support mailing
Subject: Re: [twsocket] Use of twsocket in thttpserver application


> My socket connection to other programs is done in the main thread.
Should not be a problem, but it could slow down the server.
>
> After I call connect I call application processmessages until I get
> connected and then I close.
> Do you think this could be "interfering" with the HttpServer component
> logic?

Calling Application.ProcessMessages is very dangerous and is not neccesary 
at all.
I could disturb the message pumps used by all async components.
It is most likely the cause of the problems you have.

Paul 

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

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Paul



My socket connection to other programs is done in the main thread.

Should not be a problem, but it could slow down the server.


After I call connect I call application processmessages until I get
connected and then I close.
Do you think this could be "interfering" with the HttpServer component
logic?


Calling Application.ProcessMessages is very dangerous and is not neccesary 
at all.

I could disturb the message pumps used by all async components.
It is most likely the cause of the problems you have.

Paul 


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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Chris Schofield
Hi Paul

My socket connection to other programs is done in the main thread.  

After I call connect I call application processmessages until I get
connected and then I close.

Do you think this could be "interfering" with the HttpServer component
logic?

Is doing the communication socket call in a separate thread better than in
the main thread?

Thanks for your reply
Regards
Chris

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Paul
Sent: 07 December 2009 13:42
To: ICS support mailing
Subject: Re: [twsocket] Use of twsocket in thttpserver application

I have many Https servers running 24/7.
The communication with other applications/webservices in done by several 
SslHttpCli's running in continuous threads and never had problems with it.

Add some logging in both sever and client sockets so you at least find when 
the error occurs and if it occurs during/after comunication with a client 
socket.


Paul 

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

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


Re: [twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Paul

I have many Https servers running 24/7.
The communication with other applications/webservices in done by several 
SslHttpCli's running in continuous threads and never had problems with it.


Add some logging in both sever and client sockets so you at least find when 
the error occurs and if it occurs during/after comunication with a client 
socket.



Paul 


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


[twsocket] Use of twsocket in thttpserver application

2009-12-07 Thread Chris Schofield
Hi

 

I have a web server application based on THTTPServer component.

 

As part of the processing I need to signal a separate program that an update
is required.  I use a twsocket to connect the programs tcp socket to do
this.

 

This causes some issues with the Httpserver component and it "stops" at
least 3 times a day.

 

When I run the program without the twsocket. I get no problems.

 

I simply connect to the socket and then close in the onconnect event.

 

Do you know of any issues with using Twsocket in an application that uses
THTTPServer?

 

Regards

Chris

 

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