> Would that work principally? I think so. Better performance can also be achieved using a pool of TWSocket to avoid destroying each instance when connection is closed and recreating a new one when the next connection is available. Same for the threads.
-- [EMAIL PROTECTED] http://www.overbyte.be ----- Original Message ----- From: "Arno Garrels" <[EMAIL PROTECTED]> To: "ICS support mailing" <[email protected]> Sent: Tuesday, June 13, 2006 12:59 PM Subject: Re: [twsocket] Multi-threaded server implementation : A securemethodto move a socket to a different thread context > Francois PIETTE wrote: > >> Also I think that V6 should get a secure method to move a > >> socket to a different thread context. Required only in multi-threaded > >> after Accept a client connection. > > > > In that situation, the most secure method is to do it when we get the > > socket handle from Accept() and before it is assigned to a > > TWSocketClient instance using Dup(). That instance should be attached > > the worker thread before having the handle. At that time there is not > > yet any message in the message queue which could be lost. > > It is also very important to block the listing socket as short as > possible, means to return from SessionAvailable as fast as possible. > What about something like: > - In SessionAvailable Detach client instance (not necessary if there were > an option to create a TWSocket windowless) > - Get the handle into a local variable calling Accept() > - PostThreadMessage(ThreadID, WM_ATTACH, Integer(client), SocketHandle) > - Exit from SessionAvailable. > > When the worker thread processes WM_ATTACH the client Attach and assigns > property HSocket := msg.LParam. > > Would that work principally? > > > > > -- > > [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 -- 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
