Revision 1.15 |
Revision 1.23 |
Line 24 |
Line 24 |
//! noticed immediately during the call to select in FountainSocketHandlers::CheckConnections. class FountainWireProt { public: 
|
//! noticed immediately during the call to select in FountainSocketHandlers::CheckConnections. class FountainWireProt { public: 
|
//! \brief default constructor
//! Creates an unconnected wire protocol handler
FountainWireProt(SSSWireProt* connection=NULL);
|
//! \brief Server socket constructor
//! Creates a connected wire protocol handler using the SSS wire protocol handler
//! @param connection A SSSWireProtocol connection already in place
|
|
FountainWireProt(SSSWireProt* connection);
//! \brief Client socket constructor
//! Created an unconnected wire protocol handler ready to connect
//! @param prot The SSS wire protocol to use
FountainWireProt(SSS_Protocols prot);
|
//! \brief Destructor that will close the socket and remove the file descriptor from our vector of clientSockets ~FountainWireProt(); //! \brief Connects to the specified host and port
|
//! \brief Destructor that will close the socket and remove the file descriptor from our vector of clientSockets ~FountainWireProt(); //! \brief Connects to the specified host and port
|
//! @param Host - The hostname to connect to
|
//! @param node The NodeID of the host to connect to
|
//! @param Port - The port on to connect to
//! @return SUCCESS if the connection was successful, or FAILURE if it was not
int connect(const char* Host, int Port);
//! \brief Same as the c-string equivalent function above
int connect(const string& Host, int Port);
//! \brief Same as calling connect(hostname, listenPort)
|
|
int connect(const NodeID& node); //! \brief Blocking send
|
int connect(const NodeID& node); //! \brief Blocking send
|
Line 51 |
Line 49 |
//! \brief Blocking receive //! @return A pointer to a ParseMsg object containing the received message FountainParseMessage* recvMessage();
|
//! \brief Blocking receive //! @return A pointer to a ParseMsg object containing the received message FountainParseMessage* recvMessage();
|
|
//! \brief Blocking receive
//! @return A pointer to a c-string array containing the received message
const char* recvMessage(int& length);
|
//! \brief Send a text message on the socket //! @return SUCCESS if sending the message was successful
|
//! \brief Send a text message on the socket //! @return SUCCESS if sending the message was successful
|
Line 66 |
Line 68 |
//! @param sleepTime The time in seconds to wait for data on this connection int CheckForData(int sleepTime=0);
|
//! @param sleepTime The time in seconds to wait for data on this connection int CheckForData(int sleepTime=0);
|
|
//! @return get the hostname of the host this object is connected to
const std::string& getHostname() const { return _hostname; };
|
//! The FountainSocketHandlers class needs to be a friend class so it //! has access to our static private sockets vector friend class FountainSocketHandlers; private:
|
//! The FountainSocketHandlers class needs to be a friend class so it //! has access to our static private sockets vector friend class FountainSocketHandlers; private:
|
//! private assignment operator and copy constructor since we don't
//! want people to use them
|
//! \enum FountainWireProtType
//! \brief Enumerated types to define client or server sockets
|
|
enum FountainWireProtType {
invalidType=0,
ClientSocket,
ServerSocket,
numFountainWireProtTypes
};
//! \enum FountainWireProtState
//! \brief Enumerated types to define the state of a FountainWireProt object
enum FountainWireProtState {
invalidState=0,
notConnected,
connected,
numFountainWireProtStates
};
//! \brief private unimplemented copy constructor since we don't want people to use it
|
FountainWireProt(const FountainWireProt& rhs);
|
FountainWireProt(const FountainWireProt& rhs);
|
|
//! \brief private unimplemented assignment operator since we don't want people to use it
|
FountainWireProt& operator=(const FountainWireProt& rhs);
|
FountainWireProt& operator=(const FountainWireProt& rhs);
|
|
//! \brief This function is called by the FountainWireProt destructor
void removeSocket();
//! \brief Looks up a hostname of a connected socket using the getpeername system call
void lookupHostname() throw(FountainException);
|
|
|
//! \todo make this an enum or use the enum in SSSWireProt
string state;
//! This function is called by the FountainWireProt destructor
void removeSocket(int socket);
|
//! \brief Convert a FountainWireProtType enumeration into a c-string
static const char* fountain_convert(FountainWireProtType t);
//! \brief Convert a FountainWireProtState enumeration into a c-string
static const char* fountain_convert(FountainWireProtState t);
|
|
//! enumerated value to determine if we're a server or client socket
FountainWireProtType socketType;
|
|
|
//! Vector of file descriptors for our existing open client sockets
static std::vector<int> sockets;
|
//! enumerated value to determine our state
FountainWireProtState state;
|
//! The SSSWireProt handler for each FountainWireProt object SSSWireProt* _connection;
|
//! The SSSWireProt handler for each FountainWireProt object SSSWireProt* _connection;
|
|
//! The hostname of the host this FountainWireProt object is connected to
std::string _hostname;
//! Vector of file descriptors for our existing open client sockets. Both this vector and the serverSockets vector
//! are static since they contain values needed by the FountainSocketHandlers class during it's system call
//! to select to determine which sockets have data ready.
static std::vector<int> clientSockets;
//! Vector of file descriptors for our existing open server sockets. This has to be separated from the clientSockets
//! vector because when the FountainSocketHandlers class detects data ready on an open server socket it will have
//! to create a new wire protocol handler for that socket and return it to the caller of its checkConnections method.
//! When data is ready on a clientSocket no wire protocol handler is returned since one alredy exists.
static std::vector<int> serverSockets;
|
}; #endif
|
}; #endif
|