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