Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!.POSTED!not-for-mail From: Willem Newsgroups: comp.programming Subject: Re: server Date: Tue, 4 Sep 2012 23:25:30 +0000 (UTC) Organization: Stack Usenet News Service Lines: 31 Message-ID: References: NNTP-Posting-Host: turtle.stack.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: mud.stack.nl 1346801130 66436 2001:610:1108:5010::132 (4 Sep 2012 23:25:30 GMT) X-Complaints-To: abuse@stack.nl NNTP-Posting-Date: Tue, 4 Sep 2012 23:25:30 +0000 (UTC) User-Agent: slrn/0.9.9p1 (FreeBSD) Xref: csiph.com comp.programming:2152 bob wrote: ) There are two main ways I can see to make a server that serves multiple users simultaneously. ) ) One is to use threads. ) ) The other is to use non-blocking sockets. ) ) Has anyone actually used the latter approach in practice or do they pretty much always use multiple threads? Not using threads avoids a lot of concurrency issues, race conditions and whatnot, making programming a lot simpler. All one has to worry about is to handle any single request in a short amount of time, to keep the latency acceptable. Most MUDs that I know of are single-threaded, and use 'select' calls and non-blocking sockets to service multiple users. There are usually tens to hundreds of connections to a MUD, back when they were quite popular. Basically, as long as you avoid blocking calls, you don't need threads. A hybrid approach is to use a single thread that services all the non-blocking sockets, which hands off long-running or blocking tasks to worker threads. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT