> My idea is that when this kind of request are received, I will select a
> free thread from a pool of working threads that perform the conection to
> the other server, and when the results arrives, Send() it to the client.

This will not require a thread. The connection, sending and receiving are
asynchronous.
You need a thread if you have processing or other blocking operation such as
SQL requests.

> As I understand I need first to use the ThreadDetach from the context of
> the main thread, and then call ThreadAttach at the execute method of the
> thread.

Right. This would make the socket operate in the context of the worker
thread. Note that you can still use the socket form the [main] thread and
only use a worker thread for processing. A single thread is able to sustain
something like hundreds of simultaneous sockets.

> My doubt is that after this operation finalizes, there would be more
> comunications between the server and the client, and for them I do not
> think it's a good idea to continue working at the thread context. In the
> examples I saw, there's and adittional call to ThreadDetach at the end
> of the thread execution, and my doubt here is what happens with
> subsequent communications from the client side, will they be managed
> from the main thread ? (considering that I first called ThreadDetach at
> this context)

You have to re-attach the socket to the main thread. While the socket is in
detacthed state, it will not work as expected : asynchronous notifications
are stopped.

Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be



----- Original Message ----- 
From: "Raúl Olivencia" <[EMAIL PROTECTED]>
To: <twsocket@elists.org>
Sent: Friday, December 01, 2006 6:38 AM
Subject: [twsocket] ThreadDetach


> First at all I must apologize about my english, it's not as good as it
> should be.
>
> I have a server developed using ICS which doesn't use threads. But now,
> I have a new requirementes that I think will be requiring the use of
> threads. For certain client inquiries I need to connect my server to
> another one (it will perform as a switch between systems), and that
> operation could take some time (maybe seconds)
>
> My idea is that when this kind of request are received, I will select a
> free thread from a pool of working threads that perform the conection to
> the other server, and when the results arrives, Send() it to the client.
> As I understand I need first to use the ThreadDetach from the context of
> the main thread, and then call ThreadAttach at the execute method of the
> thread.
>
> My doubt is that after this operation finalizes, there would be more
> comunications between the server and the client, and for them I do not
> think it's a good idea to continue working at the thread context. In the
> examples I saw, there's and adittional call to ThreadDetach at the end
> of the thread execution, and my doubt here is what happens with
> subsequent communications from the client side, will they be managed
> from the main thread ? (considering that I first called ThreadDetach at
> this context)
>
> I appreciatte any help regarding this,
>
> Thanks in advance,
>
> Raúl Olivencia
> Montevideo, Uruguay
>
> -- 
> 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

Reply via email to