Hash Tables
-
Hi, Hash Tables can contain lots of objects and are very useful. But if you want to organise a whole bunch of TCPClient objects are they the way to go or is there some other way? If Hashtables are the best way to go then how would you go about checking when data has arrived and knowing which object to send data from? And where would threading come into this? Would you create a hashtable of threads running TCPClients or create a new thread only when needed? You've probably guessed I'm trying to develop my own server class, there's no specific reason for this aside from the fact I want to learn how to do this sort of thing. Any help is appreciated.
--- Assimilating Knowledge irc.heavenlyplace.net #vb
-
Hi, Hash Tables can contain lots of objects and are very useful. But if you want to organise a whole bunch of TCPClient objects are they the way to go or is there some other way? If Hashtables are the best way to go then how would you go about checking when data has arrived and knowing which object to send data from? And where would threading come into this? Would you create a hashtable of threads running TCPClients or create a new thread only when needed? You've probably guessed I'm trying to develop my own server class, there's no specific reason for this aside from the fact I want to learn how to do this sort of thing. Any help is appreciated.
--- Assimilating Knowledge irc.heavenlyplace.net #vb
Start simple. Use a new thread for each TCPClient. Actually, use one thread for the TCPListener to get new connections. On each new connection (TCPClient), invoke a new thread to handle it. When the TCPClient closes, you let the thread finish. In real world use, you'll find that this is very effective and a lot more scalable than you might at first think.