untermud/DOC/
untermud/DOC/U/
untermud/DOC/U/U-examples/
untermud/DOC/internals/
untermud/DOC/wizard/
untermud/MISC/
untermud/MISC/dbchk/
untermud/RWHO/
untermud/RWHO/rwhod/
NETWORK - layout of the network I/O subsystem.
-------


The network I/O subsystem is strictly partitioned from the rest of
the server code. In any case where access is needed into I/O layer
data structures, it is performed through functions that do "generic"
operations through "generic" interfaces. IE: "say 'foo' to player",
or "disconnect this player" or "dump the WHO list to this player".
This entails a little additional complexity but is well worth the
price.


FUNCTIONAL SPEC & INTERFACES
----------------------------
The network layer will support generic operations for communicating
to players, as well as taking total responsibility for multiplexing
input from players. This frees the rest of the MUD code from having
to concern itself with where the input came from - it simply gets
lines of text, and the ID of the object that produced that line of
commands. The network code will be called in a tight loop from the
higher level main entry point of the MUD, and is expected to return
nonzero unless a *FATAL* error has occurred. The only higher-level
interfaces that tie into the network layer are the following:

io_init()	/* initialize network layer (done once) */
io_loop()	/* main I/O multiplexing loop - calls run() and commands */
say(who,what,0)	/* output text to player "who" - null-terminated list */
io_drop(who)	/* drop player "who"'s connection */
io_who(who)	/* display entire WHO list to player "who" */
io_which(who,player)	/* display WHO entry for "player" to player "who" */
io_sync()	/* flush any pending output (called from upper level) */
io_shutdown()	/* shut down the entire network layer */

The most crucial functions here are say(), io_loop() and io_sync() which
will typically represent most of the activity of the MUD. Inside the
main program loop, the calling sequence resembles:

	io_init();

	while(mud_is_running_flag) {
		if(io_loop())
			break;
		if(io_sync())
			break;
	}
	
	io_shutdown();
	exit();

The code in I/O loop is expected to hand lines of command input to run()
as they are entered by the players. It ignores any errors run() may return,
since that has nothing to do with the state of I/O processing. The cmd_who()
command is a pain, but is necessary to implement in this manner, since not
all network layers will have the same type of information available to
them about player connected states, etc, and this allows the code to be
portable The simplest and most elegant implementation of cmd_who is as follows:

cmd_who(argc,argv,who,aswho)
int	argc;
char	*argv[];
char	*who;
char	*aswho;
{
	say(who,"Huh?\n",(char *)0);
}


mjr. '91