On Oct 18, 2007, at 05:36, Ana Onarres wrote:

> I am confused. Clients is the property of TWSocketServer, not of 
> ClientThread. ClientThread extends TThread, for controling every 
> connection, every client socket.

        I was talking about the TWSocketThrdServer, not the TWSocketServer, I 
am very sorry for the confusion.  I thought that since you were 
determined to using threads, why would you not use the component that 
was designed for this, encapsulating all that the ThrdSrv_V1/V2 
examples show?  The examples for ThrdSrv_V1 and ThrdSrv_V2 where 
written before TWSocketThrdServer was made.  ThrdSrv_V3 was then made 
for the TWSocketThrdServer.  Apparently the interface of both 
components is different and I am sorry for causing confusion on this.

        I am not familiar with TWSocketServer in a multi-threaded use, but the 
demo applications show how to use it.  To send data to all the clients, 
you must be aware of thread synchronization:  each client is running on 
its own ClientThread, so it is not safe to access them from the main 
thread using the TWSocket.Clients collection.  The first demo shows 
this, I believe, by sending the Welcome Banner from the main thread.

        Are you absolutely sure that you need multiple threads for your 
clients?  I encountered the same complexity a week ago and was finally 
convinced that my application did not need the multiple threads, and 
switched to using TWSocketServer on a single thread (my application 
spawns a worker thread for the server, but it runs within that 
context), and everything became easier and simpler -- yet its still 
fast and able to cope with many hundreds of concurrent clients.  If 
your clients need to do some very extensive processing that may block 
the rest of the clients, then perhaps it would be better to have the 
client itself spawn a worker thread to perform the processing.  That 
way the synchronicity issues are contained within the client, instead 
of having to complicate the server with various threads.

>  If the server has connected three clients, is there 3 TThrdSrvClient 
> or 3 ClientThread?
> TThrdSrvClient is:

There are three of each:  Three ClientThreads, each with one 
TThrdSrvClient attached.  The TWSocketThrdServer component can handle 
more than one client per thread, so depending on your configuration, 
all clients may be attached to the same thread, or to different ones 
(the default is one client per thread).

> Is there some help page over how to use the TWSocketServer?

I know this sounds trite, but the demo applications and the source 
code, are your best help.  Not to mention this very list.  There have 
been various documentation projects started in the past, and most of 
them are available from the OverByte web site, but none of them are 
complete or comprehensive.  There is currently a Wiki project, but it 
needs volunteers, and it is far from completed.  Of course, you are 
welcome to contribute to the Wiki and post instructions, samples, or 
help topics based on your experiences.  Just contact Francois for an 


        DZ-Jay [TeamICS]

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