April 1999
- In-Game Languages Eli Stevens {KiZurich}
- In-Game Languages Per Vognsen
- In-Game Languages Chris Gray
- In-Game Languages Caliban Tiresias Darklock
- In-Game Languages Eli Stevens {KiZurich}
- In-Game Languages Matthew D. Fuller
- In-Game Languages Mik Clarke
- In-Game Languages Michael Hohensee
- In-Game Languages Ben Greear
- In-Game Languages Michael Hohensee
- In-Game Languages Mik Clarke
- In-Game Languages Hans-Henrik Staerfeldt
- In-Game Languages David Bennett
- In-Game Languages Richard Woolcock
- In-Game Languages Hans-Henrik Staerfeldt
- In-Game Languages Caliban Tiresias Darklock
- In-Game Languages Hans-Henrik Staerfeldt
- In-Game Languages Andrew Ritchie
- In-Game Languages Matthew D. Fuller
- In-Game Languages adam@treyarch.com
- forward: consistency Ola Fosheim Grøstad
- Confined Gameworld Ling
- Confined Gameworld Caliban Tiresias Darklock
- Confined Gameworld Richard Woolcock
- Confined Gameworld Eli Stevens {KiZurich}
- Confined Gameworld The Wildman
- Confined Gameworld Koster, Raph
- User centered? Ola Fosheim Grøstad
- User centered? Caliban Tiresias Darklock
- User centered? Marc Bowden
- User centered? Adam Wiggins
- User centered? Richard Woolcock
- User centered? Benjamin D. Wiechel
- User centered? Koster, Raph
- target audience Matthew Mihaly
- target audience Caliban Tiresias Darklock
- target audience Marc Bowden
- Fw: Self-organizing worlds (was: Elder Games) Kylotan
- Fw: Self-organizing worlds (was: Elder Games) Matthew Mihaly
- ScryMUD 1.8.11 released. Ben Greear
- Mud driver architecture info B. Scott Boding
- Blending graphics with text u1391470
- Blending graphics with text Laurel Fan
- Blending graphics with text Kylotan
- Blending graphics with text Chris Gray
- Blending graphics with text J C Lawrence
- Blending graphics with text Caliban Tiresias Darklock
- Blending graphics with text Chris Gray
- Blending graphics with text Ola Fosheim Grøstad
- Blending graphics with text Hans-Henrik Staerfeldt
- Blending graphics with text Mik Clarke
- Blending graphics with text u1391470
- Blending graphics with text claw@kanga.nu
- Blending graphics with text Alex Stewart
- Blending graphics with text J C Lawrence
- Virtual machine design Shane King
- Virtual machine design Alex Stewart
- Virtual machine design Jo Dillon
- Virtual machine design Ben Greear
- Virtual machine design Niklas Elmqvist
- Virtual machine design Shane King
- Virtual machine design Ben Greear
- Virtual machine design claw@kanga.nu
- Virtual machine design Alex Stewart
- Virtual machine design Felix A. Croes
- Virtual machine design Eli Stevens {KiZurich}
- Virtual machine design Mik Clarke
- Virtual machine design Schubert, Damion
- Virtual machine design Ben Greear
- Virtual machine design Ben Greear
- Virtual machine design Felix A. Croes
- Virtual machine design Matthew Mihaly
- Virtual machine design Hans-Henrik Staerfeldt
- Virtual machine design claw@kanga.nu
- Virtual machine design Mik Clarke
- Virtual machine design Oliver Jowett
- Virtual machine design Chris Gray
- Virtual machine design claw@kanga.nu
- Virtual machine design Chris Gray
- Virtual machine design Ola Fosheim Grøstad
- Virtual machine design claw@kanga.nu
- Virtual machine design Petri Virkkula
- Virtual machine design Ben Greear
- Virtual machine design Chris Gray
- Virtual machine design Ola Fosheim Grøstad
- Virtual machine design Nathan F Yospe
- Virtual machine design Ola Fosheim Grøstad
- Virtual machine design Petri Virkkula
- Virtual machine design Jon A. Lambert
- Virtual machine design Koster, Raph
- Virtual machine design Jon A. Lambert
- Virtual machine design Chris Gray
- Rebooting (was: Virtual machine design) Eli Stevens {KiZurich}
- Game design highpoints (was Virtual machine design) claw@kanga.nu
- Sockets Quzah [softhome]
- Sockets Alex Stewart
"Quzah [softhome]" <quzah@softhome.net> wrote:
> What is the main difference between and benifit of using:
>
> (1) asynchronous notification
> <versus>
> (2) versus non-blocking
> <versus>
> (3) using select
Technically, there are two different issues here, and you'll probably need some
combination of the above options.
First, some definitions:
Blocking:
(you didn't mention this in your list, but it's the most basic starting
point for socket programming, so it should be discussed. It sounds like
this is where you are currently with your program) When you write
to a socket, it sends the data out. If there isn't enough buffer space in
the output buffer for everything you feed it, it will send out as much as
it can, wait for more space, send out more, etc, and not return until it's
written everything. When you read from a socket, it returns any data
which has come in. If there's no data in the input buffer, it will wait
until there is some and then return that.
This has some obvious drawbacks for handling multiple sockets in the same
application. When you're reading/writing with one, your entire application
is tied up until the operation completes on that socket.
Non-Blocking:
When a socket is set non-blocking, if you write to it and there isn't
enough buffer space for all of the data you are writing, it writes as much
as it can and returns the amount written. You can then try again to write
the rest of it at a later time. When you read from a non-blocking socket,
if data is available in the input buffer, it is returned. If no data is
currently available, the call returns without any data.
In this way, socket IO never suspends program execution any longer than
absolutely necessary, but it does mean you need to do a bit more
housekeeping on your end (knowing when to try writes again, making sure you
pick up data in a timely manner when it comes in, etc). This is where
notification methods come in:
Repeated polling:
This is the most obvious way to check for events on sockets. Just
repeatedly loop through them and check to see if any are ready to do
anything you want to do. While there are a few (very unusual)
circumstances where this may actually be useful, in general this is a Bad
Thing(tm), as it means even when your program is completely idle, it'll be
using up huge amounts of procesing time just doing nothing. There are
better ways.
Asyncrhonous notification:
This is essentially "interrupt driven" network handling. When a socket has
data (or is available for writing more data out), the system notifies the
application (typically via a signal or a pipe), at which point the
application services the socket and then continues on with whatever it was
doing when it was interrupted.
The main problems with this are that as far as I know, nobody's come up
with a very good implementation of this for unix (certainly not a portable
one), and that this method (despite its somewhat cleaner conceptual model)
doesn't really gain anything over other already well-accepted methods. In
any case if you're starting out it's probably better to go with one of the
more common methods which already have a lot more documentation and
examples available.
Select/poll:
This is the most common way to deal with network events, and is probably
what you want to use. This method involves setting up a structure
indicating what sockets (or other file descriptors) you're interested in
and what types of events (ready-for-write, data-available-for-read, etc)
you're interested in for each socket. You then pass this information to
the select() or poll() system call, which sleeps until something happens
(or a timeout you specify expires). When one of the events you're waiting
on occurs, it returns with an indication of what's happened to which
sockets. Based on this information, you can then do whatever operations
are appropriate, and then return to select() or poll() again to wait for
the next event.
In case you're wondering, select() is the BSD version and poll() is the
SysV/POSIX version of more or less the same sort of thing. They use
different types of structures and semantics for some things, but when it
comes right down to it the difference between their functionality is
basically trivial (particularly since in most modern OSes, the select()
call is actually a wrapper around poll() anyway). Since poll() is now the
standard for, you might want to become familiar with it, but on the other
hand, select() has a lot more in the way of examples floating around to
play with, so it's up to you.
Anyway, so what you're probably looking for is using a combination of
non-blocking sockets with select() or poll()..
-alex
-------------------------------------------------------------------------------
Alex Stewart - riche@crl.com - Richelieu @ Diversity University MOO
http://www.crl.com/~riche
"For the world is hollow, and I have touched the sky." - Sockets Quzah [softhome]
- Sockets Jo Dillon
- Sockets Jon A. Lambert
- Sockets Jon A. Lambert
- Sockets Chris Gray
- Sockets Petri Virkkula
- Sockets Caliban Tiresias Darklock
- Sockets Alex Stewart
- ScryMUD 1.8.13 snapshot released. Ben Greear
- Interview I did that may interest you Koster, Raph
- Censorship Greg Munt
- Censorship Ben Greear
- Censorship Matthew Mihaly
- Censorship Shawn Halpenny
- Censorship Darren Henderson
- Censorship Quzah [softhome]
- Censorship Hans-Henrik Staerfeldt
- Python B. Scott Boding
- Python Gaffney, Jeremy
- AW: Censorship Hofbauer Heinz
- AW: Censorship Matthew Mihaly
- AW: Censorship Damion Schubert
- Censorship, Virtual v Artificial Worlds, Python Greg Munt
- Censorship, Virtual v Artificial Worlds, Python Matthew Mihaly
- Censorship, Virtual v Artificial Worlds, Python Ben Greear
- Censorship, Virtual v Artificial Worlds, Python Matthew Mihaly
- Censorship, Virtual v Artificial Worlds, Python Matthew Mihaly
- Censorship, Virtual v Artificial Worlds, Python Ben Greear
- Censorship, Virtual v Artificial Worlds, Python Dan
- Censorship, Virtual v Artificial Worlds, Python Matthew Mihaly
- Censorship, Virtual v Artificial Worlds, Python Marian Griffith
- Censorship, Virtual v Artificial Worlds, Python Benjamin D. Wiechel
- Censorship & Its Impact On World Immersion Greg Munt
- Censorship & Its Impact On World Immersion Matthew Mihaly