I am trying to keep my skills up since I don't get to code at work and I am visiting some old college projects and trying to improve on them. I have a generic TCP server and client. I am trying to get the TCP server to accept multiplt connections. I know that I need threads, but can't figure it out. Do I listen on the socket and then spawn a new thread when ever a client tries to connect? If someone could type in some quick pseudocode that would be greatly appreciated. I don't need actual code, just some pseudocode to get me started. Thanks a bunch.
Originally posted by Jack Dawson: Do I listen on the socket and then spawn a new thread when ever a client tries to connect?
Da.In the ConnectionHandler, you just talk to the socket and close it when you're done. If performance is important you would use a thread pool rather than spawning new threads for every client (and if performance is really important and you can afford to be cutting edge, look into JDK 1.4 java.nio.*). HTH - Peter