Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #2152

Re: server

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!.POSTED!not-for-mail
From Willem <willem@turtle.stack.nl>
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 <slrnk4d3fa.2hg5.willem@turtle.stack.nl> (permalink)
References <ded7ddda-f73a-4277-a20a-524923f145f8@googlegroups.com>
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

Show key headers only | View raw


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

Back to comp.programming | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

server bob <bob@coolfone.comze.com> - 2012-09-04 14:04 -0700
  Re: server "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2012-09-04 23:48 +0200
  Re: server Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-04 15:39 -0700
  Re: server Willem <willem@turtle.stack.nl> - 2012-09-04 23:25 +0000

csiph-web