View Single Post
Old Apr 22nd, 2008, 3:41 AM   #5
Freaky Chris
Hobbyist Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 169
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: Confused about simple multi-threaded server

Im new to Java myself but i that changing the way you have threaded your server may be an idea.

For example you are spawning a new tread of the entire program. Perhaps you would be better of having the main class run an infinite loop accepting connection from clients. Once it has recieved a client from socket.accept() the you can pass that to a new Threaded class that deals with all of the input and outputs to that socket.

This may help to tidy up the server and make it clearer what is going on. Also it means that multiple clients can connect at the same time if you require this.

Cheers,
Chris
__________________
Who said i couldn't program
sarcasm = raw_input('Type in a sarcastic remark: ')
print sarcasm
Freaky Chris is offline   Reply With Quote