Original Post
Hi, let me start off with I am using c# though I don't think it matters in this query. Plus what I am attempting is a simple chat program and am using TCP. In my server, I have 3 threads. A=Connection Thread:Uses accept to allow users to login at anytime of server operation B=Select Thread:Uses select to find which sockets in an ArrayList have data to receive C=Receive Buffer Processor Thread: Processes the receive buffer Now, for 2 out of 3 threads, B and C, each has methods associated with them. For B, is the Receive method which separates the incoming streams into packets. Then stuffs those into the Receive buffer; an ArrayList. For C, the methods corresponds to different packet types (Packet processes) and for each packet process, corresponding methods to deal with separate versions of each packet type. I realize C seems a bit confusing, so here is an hierarchal view Each alphabetic list is its own function as with the numeric list. There are others but that should suffice. Each thread runs full speed (well, with a Thread.Sleep(0) after each iteration) using Synchronized ArrayLists. No "heartbeat" or "Process only 20 packets per iteration" implemented as I have not (yet) had a need to do so. Is this a reasonably good implementation or is there another route I should take? I don't want to run into a wall down the road that will cause me to do a re-write. So I thought I would get some opinions on what I have so far. Thanks for any insight! EDIT: As a separate question, is a synchronized ArrayList good enough or should I still use locks for the data? http://msdn2.microsoft.com/en-us/library/system.collections.arraylist.synchronized(VS.71).aspx Says its thread safe, but I just wanna hear some opinions about it. [Edited by - Imgelling on May 23, 2007 12:47:54 AM]
Receive buffer processor
A: Error Packet
1. Connection reset by host forcibly
2. other errors
B: Text Packet
1. Global text
2. Private text