[Tutor] More Q's on Socket Programming

Alan G alan.gauld at freenet.co.uk
Wed Aug 3 23:56:05 CEST 2005


> chatting with untill they reply!! I also have one computer as the 
> server and another as the client.... can I have a dedicated server 
> program that handles two clients instead of having a direct connect?

Yes, but usually the way to do that is to have the server listening 
for
requests and then spawning either another process to handle the 
request
(typically using fork() ) or to start a separate thread. Forking is
slightly easier IMHO but threading is more efficient.

That way you can support multiple clients at once. Thats pretty much
how most web srvers work, they listen for http requests, spawn a
thread/process to respond with the html and carry on listening for
the next request on port 80.

Alan G. 



More information about the Tutor mailing list