FountainSocketHandlers Class Reference
[Wire Protocol]

A class for checking previously opened connections for data and detecting incoming connections. More...

#include <FountainSocketHandlers.h>

Inheritance diagram for FountainSocketHandlers:

BambooLib::ServerSocketHandlers List of all members.

Public Member Functions

FountainWireProtPtr CheckConnections ()
 Checks existing connections for data to be read and listening sockets for incoming connections.

Static Private Member Functions

static void addSocket (int socket)
 Add an open file descriptor to the open sockets vector.
static void removeSocket (int socket)
 Remove an open file descriptor from the open sockets vector.

Friends

class FountainWireProt

Detailed Description

A class for checking previously opened connections for data and detecting incoming connections.

This class inherits publicly from the BambooLib::ServerSocketHandlers class and overloads the CheckConnections method. It has to do this since the BambooLib::ServerSocketHandlers class does not maintain a list of previously opened sockets. This is fine for transient connections which are closed immediately after servicing the request message for that connection. However, each Fountain daemon maintains persistent connections to other Fountain node daemons. To respond to requests from each node's parent connection in a timely fashion, this class needs to break out of the select system call when one of the following conditions is true:

It accomplishes the first requirement by using the BambooLib::ServerSocketHandlers::CheckConnections method since it was designed to listen for incoming connections. The second requirement is accomplished by maintaining a std::vector<int> object containing the file descriptors of all previously opened sockets. These sockets are created in two places:

  1. The connections created by the BambooLib::ServerSocketHandlers::CheckConnections method. These are called "server" sockets.
  2. The connections created manually by Fountain components by the FountainWireProt::Connect method. These are called "client" sockets.

This client and server socket distinction is only in place to show where and how they are created. In the context of this class and Fountain components, no distinction is made between client or server sockets. The open socket vector is maintained in three places:

  1. When a server socket is created, its file descriptor is added to the vector
  2. When a client socket successfully connects to a remote host, its file descriptor is added to the vector
  3. When a FountainWireProt object is deleted, its destructor removes the file descriptor from the vector.

The open socket vector itself is defined in an anonymous namespace in the FountainSocketHandlers.cpp file. The methods to add and remove a file descriptor to the vector are private. The FountainWireProt class is a friend class of this class so it can access these methods.


Member Function Documentation

FountainWireProtPtr FountainSocketHandlers::CheckConnections  ) 
 

Checks existing connections for data to be read and listening sockets for incoming connections.

Return values:
FountainWireProtPtr The incoming connection or NULL if we timed out

Reimplemented from BambooLib::ServerSocketHandlers.


The documentation for this class was generated from the following files:
Generated on Wed Mar 8 14:43:33 2006 for Fountain by  doxygen 1.4.6