Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2152
| From | Willem <willem@turtle.stack.nl> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: server |
| Date | 2012-09-04 23:25 +0000 |
| Organization | Stack Usenet News Service |
| Message-ID | <slrnk4d3fa.2hg5.willem@turtle.stack.nl> (permalink) |
| References | <ded7ddda-f73a-4277-a20a-524923f145f8@googlegroups.com> |
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
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