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?

> --
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to