> Question: Is there a thread safe pattern or approach for scanning the 
> client
> sockets in the TWSocketServer collection from a different thread?

Accessing the TWsocketServer.Client[] is /not/ thread safe. You /must/ 
access it only from the thread which created the TWSocketServer instance.

--
Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
--
[EMAIL PROTECTED]
http://www.overbyte.be



----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <twsocket@elists.org>
Sent: Friday, November 10, 2006 11:57 PM
Subject: [twsocket] Scanning Client Socket and Housekeeping from 
differentthread...


> Hello.
>
>
>
> I have a question that relates to doing basic client connection 
> housekeeping
> from a different thread than the TWSocketServer's thread.
>
>
>
> System Overview:  I have a server application that uses a TWSocketServer.
> The TWSocketServer is located on the main form, thus it is in the main
> thread.  All inbound packets are handled from the app's main thread by 
> this
> TWSocketServer.
>
>
>
> If an inbound packet requires a CPU intensive process, an event is queued 
> by
> a thread pool manager for handling those processes out-of-line.  The
> threaded tasks within the thread pool may generate response packets from
> their own thread space.
>
>
>
> This is all working wonderfully.  Now, I need to implement some basic
> housekeeping on the client sockets.  Basically, this entails a simple
> pattern or iterating through all the client sockets periodically and
> checking for dead sockets and other types of issues.  I have a KeepAlive
> packet system that simply pings this server from the client periodically 
> and
> updates a LastTransmit / LastReceive time flags.  Also, for security
> purposes, initial secure channel handshaking mandates that untrusted or
> unpromoted connections be dropped within a certain time length.
>
>
>
> So, I could simply implement the housekeeping in the main thread with a
> basic TTimer event and scan the client sockets there from within the main
> thread itself.  However, I am concerned about causing a performance 
> slowdown
> when this occurs, by scanning from within the main thread.
>
>
>
> However, I could also spawn a thread for doing this housekeeping.
>
>
>
> Question: Is there a thread safe pattern or approach for scanning the 
> client
> sockets in the TWSocketServer collection from a different thread?  Does a
> specific client socket need to be locked somehow when checking it?  Or is
> this even necessary or relevant?
>
>
>
> Or would it just be best to scan from within the app's main thread?  The
> client sockets are persistent sessions and I do not expect to have more 
> than
> 200 to 300 on a particular server, although that limit is not currently
> decided.
>
>
>
> Just wondering what your advice would be for which direction to take: 
> Main
> thread or separate thread for housekeeping chores?
>
>
>
> Thanks much!  Love ICS!
>
>
>
> Hoby
>
>
>
> -- 
> 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