6b3 Subj : Re: Socket programmation with threads To : comp.programming.threads From : spano Date : Tue May 24 2005 03:00 am Phil Frisbie, Jr. wrote: > christophe.anthon@gmail.com wrote: > >> Hi, >> I have started with socket programmation and well no problem since now. >> >> But now i want to thread connections for the server and I got stuck in >> the topic of threads. >> I think in this group some guys can help me about how to use threads in >> socket programmation. I read some sites, but well.. no luck. Can >> perhaps somebody send me some code which simply explain how to use >> threads or perhaps someone here has already programmed sockets with >> threads and could mail me some scripts. > > > First you need to tell what your application is and us WHY you think you > need threads. Is this just an exercise? > > Are you trying to make a scalable server? There are better ways than > threads... > >> Thank you! Have a nice day, Christophe >> > Hello, Seems that using threads for servers which need to handle concurrency is the natural way today (you could try processes, but there would be a great overhead to this, ... implies typically lots of IPCs ....) Otherwise you maybe meant: better ways than one connection <--> one server thread ? Yes, it's a too trivial demultiplexing strategy in my opinion. Most of the time, it is useful to use some select POSIX syscall, and dispatch incoming requests / messages to threads in a threadpool ... You can also apply various buffering strategies. I suggest the OP checks in some books/presentations by Schmidt (on POSA or ACE) for discussions on these topics. Best regards, Vincent. . 0