Hi Adam,

You have to make a custom message handler and post a message to it. Then
this handler will execute outside the event. Something like this:

const
WM_RECONNECT = WM_USER + 1;
private
procedure WMReconnect(var Msg: TMessage); message WM_RECONNECT;

procedure TSomething.SocketSessionClosed;
begin
PostMessage(Handle, WM_RECONNECT, 0 , 0);

If your TSomething does not have a Handle then you have to create one with
AllocateHWND procedure (and free it later) and you have to make a WinProc
procedure.

If it is threaded code then you also have to make a message pump. Please ask
if something is not clear.

-- 
mvg, Wilfried
http://www.mestdagh.biz
http://www.comfortsoftware.be
http://www.expertsoftware.be


> -----Oorspronkelijk bericht-----
> Van: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org]
> Namens Adam Burgoyne
> Verzonden: zondag 11 september 2011 16:42
> Aan: 'ICS support mailing'
> Onderwerp: Re: [twsocket] DLL implementation advice (or example)...
> 
> Hi, Wilfried
> 
> I'm pleased to say that I've made good progress with the system so far
> but
> I'm not sure how to best implement server alternation.
> 
> Very simply, the current system works with a main server and a fail-
> over
> server.
> 
> All initial connections are made to the main server (I have this part
> working fine) but, if the main server is unavailable then clients will
> attempt to connect to the fail-over server.
> 
> What I need the client to do is try connecting to the other server if
> the
> current connection cannot be made within a few seconds or if the
> current
> connection gets dropped for any reason.
> 
> I've started playing around with it but I'm not sure I'm doing things
> correctly.
> 
> I saw a post (from you I think) in the ICS help that mentioned sending
> a
> message from the "sessionclosed" procedure but it didn't specify what
> message to send.
> 
> Is there a list of messages that can be used with ICS?
> 
> Regards, Adam
> 
> 
> -----Original Message-----
> From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org]
> On
> Behalf Of Wilfried Mestdagh
> Sent: 09 September 2011 09:04
> To: 'ICS support mailing'
> Subject: Re: [twsocket] DLL implementation advice (or example)...
> 
> Hi Adam,
> 
> > The problem is that the DLL is quite unstable so I was trying to use
> a
> > different approach and hoping to get better stability.
> 
> Are we talking about TWSocket in your second approach?
> 
> > Right now, I have the basic DLL test project running - it is
> > connecting to my server but the worker thread is not terminating so
> > either the server is not sending a response or the ondatareceived
> > event is not triggering.
> 
> I'm not sure if a TDatamodule is thread safe. Anyway I never used it.
> Note
> that what you create in a constructor is in main thread context. You
> have to
> create (and destroy) the components in the Execute method of that
> thread. If
> you do not then you have a false thread.
> 
> --
> mvg, Wilfried
> 
> --
> 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

Reply via email to