
		      Initialization of JChannel
		      ==========================



1. Creation of JChannel: new JChannel():
----------------------------------------

- Creates new protocol stack: new ProtocolStack()

- Calls ProtocolStack.Setup():

  - Creates all layers and sets up queues between layers, ready to process events




2. JChannel.Connect():
----------------------

- Calls ProtocolStack.Start():

  - Sends a START event from bottom of the stack upwards

  - UDP initializes its sockets (unicast and multicast). From now on, it is able to
    receive messages. Then it sends a SET_LOCAL_ADDRESS event up the stack. 
    This allows various layers to cache the local address of the stack.
    Then it sends a START_OK event up the stack.

  - When ProtocolStack.Start() receives the START_OK, it returns. (Note that there is also a
    timeout, if it expires, ProtocolStack.Start() throws an exception)


- Sends down a CONNECT event, waits for CONNECT_OK:

  - Various layers process this event and pass it down

  - GMS passes the event down. Then it establishes the initial membership. Finally it
    passes up a CONNECT_OK event

  - JChannel.Connect() waits for CONNECT_OK event, or, it the timeout expires, returns
    without having received a CONNECT_OK



3. JChannel.Disconnect():
-------------------------

- Sends down a DISCONNECT event, waits for a DISCONNECT_OK event:
    
  - GMS updates the membership. Then it passes down the event. Then it sends up a
    DISCONNECT_OK event.

  - JChannel.Disconnect() waits for the DISCONNECT_OK event, or, if the timer expires,
    throws an exception



- Stops the protocol stack: ProtocolStack.Stop():
  
  - Sends a STOP event down the stack

  - When the lowest layer (UDP) receives STOP, it closes all its sockets. Then it sends up
    a STOP_OK event

  When ProtocolStack.Stop() receives STOP_OK, it returns. Otherwise, if the timer expires,
  it returns too.



4. JChannel.Close():
--------------------

- Calls JChannel.Disconnect() if still connected

- Clears the JChannel-internal messages queues (for incoming messages)

- Calls ProtocolStack.Destroy():

  - Destroys all queues between layers. Destroys all layers

- A JChannel.Close() makes the channel unusable. Any calls to it will result in an
  exception. To participate in a group, a new JChannel has to be created.

