Package driver :: Module network
[show private | hide private]
[frames | no frames]


This is the network module which holds the MasterServer and the Connection objects and handles all socket interface things.

It handles connections and disconnections as well as user input. It kicks off appropriate hooks and events accordingly.

A connection<handling connections> happens whenever the master socket is tickled.

Connections are handled this way:
  1. the Master socket gets tickled and generates a Connection object which wraps around the socket object
  2. the network thread tosses a HookEvent onto the event queue which will send a message to the "connect" Hook with the connection as an argument
  3. (some time passes...)
  4. the HookEvent is executed and sends a message to the "connect" Hook with the connection as an argument--functions that don't want the connection to happen will mark the Connection object as such with a _do_not_connect = 1
  5. at the end of the hook (the last item), the network checks for the _do_not_connect flag:
      if _do_not_connect == 0:
        1. locks the connections list
        2. adds the connection to the list
        3. unlocks the connections list
        1. sends a HookEvent for "disconnect" with the Connection object
A disconnect<handling disconnects> can happen for a variety of reasons:
  1. they drop their connection (linkdeath) which causes an Exception in the network thread
  2. they quit out which happens in the event handling thread
  3. a connection occurs, but someone marks it as _do_not_connect so it immediately gets disconnected
When a disconnect happens:
  1. a HookEvent is created with the Connection disconnecting and why it's being disconnected (QUIT or LINKDEATH)
  2. (some time passes...)
  3. at the beginning of the hook (the first item), the network removes the connection from the list
  4. the mudlib does whatever it does with disconnects

Connection The connection object handles dealing with the user on a socket level.
MasterServer The MasterServer handles all the incoming network connections and holds a series of Connection objects.

Variable Summary

Variable Details



Generated by Epydoc 2.0 on Wed Jan 21 21:00:06 2004