#include <PPTClient.h>
Inheritance diagram for PPTClient:
Public Member Functions | |
PPTClient (const string &hostStr, int portVal, int timeout) | |
PPTClient (const string &unix_socket, int timeout) | |
~PPTClient () | |
virtual void | initConnection () |
virtual void | closeConnection () |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
virtual void | send (const string &buffer, map< string, string > &extensions) |
Send a message to the server. | |
virtual bool | receive (map< string, string > &extensions, ostream *strm=0) |
receive a chunk of either extensions into the specified map or data into the specified stream | |
virtual string | exit () |
virtual void | sendExtensions (map< string, string > &extensions) |
send the specified extensions | |
virtual void | sendExit () |
Send the exit token as an extension. | |
virtual Socket * | getSocket () |
virtual bool | isConnected () |
virtual void | setOutputStream (ostream *strm) |
virtual ostream * | getOutputStream () |
virtual void | brokenPipe () |
Protected Member Functions | |
virtual int | readBuffer (char *inBuff, unsigned int buff_size) |
read a buffer of data from the socket | |
virtual int | readBufferNonBlocking (char *inBuff) |
read a buffer of data from the socket without blocking | |
virtual void | send (const string &buffer) |
sends the buffer to the socket | |
virtual void | sendChunk (const string &buffer, map< string, string > &extensions) |
Send a chunk to the server. | |
virtual void | read_extensions (map< string, string > &extensions, const string &xstr) |
the string passed are extensions, read them and store the name/value pairs into the passed map | |
virtual void | receive (ostream &strm, unsigned short len) |
receive from the socket the number of bytes specified until done | |
Protected Attributes | |
Socket * | _mySock |
ostream * | _out |
bool | _brokenPipe |
Definition at line 40 of file PPTClient.h.
PPTClient::PPTClient | ( | const string & | hostStr, | |
int | portVal, | |||
int | timeout | |||
) |
Definition at line 55 of file PPTClient.cc.
References Connection::_mySock, Socket::connect(), and Socket::isConnected().
Here is the call graph for this function:
PPTClient::PPTClient | ( | const string & | unix_socket, | |
int | timeout | |||
) |
Definition at line 67 of file PPTClient.cc.
References Connection::_mySock, and Socket::connect().
Here is the call graph for this function:
PPTClient::~PPTClient | ( | ) |
Definition at line 96 of file PPTClient.cc.
References Connection::_mySock, and closeConnection().
Here is the call graph for this function:
void PPTClient::initConnection | ( | ) | [virtual] |
Implements PPTConnection.
Definition at line 110 of file PPTClient.cc.
References BESError::get_message(), PPT_PROTOCOL_BUFFER_SIZE, PPTProtocol::PPT_PROTOCOL_UNDEFINED, PPTProtocol::PPTCLIENT_TESTING_CONNECTION, PPTProtocol::PPTSERVER_AUTHENTICATE, PPTProtocol::PPTSERVER_CONNECTION_OK, PPTConnection::readBufferNonBlocking(), and PPTConnection::send().
Referenced by CmdClient::startClient().
Here is the call graph for this function:
void PPTClient::closeConnection | ( | ) | [virtual] |
Implements PPTConnection.
Definition at line 206 of file PPTClient.cc.
References Connection::_brokenPipe, Connection::_mySock, Socket::close(), BESError::get_message(), and PPTConnection::sendExit().
Referenced by CmdClient::shutdownClient(), and ~PPTClient().
Here is the call graph for this function:
void PPTClient::dump | ( | ostream & | strm | ) | const [virtual] |
dumps information about this object
Displays the pointer value of this instance
strm | C++ i/o stream to dump the information to |
Reimplemented from PPTConnection.
Definition at line 238 of file PPTClient.cc.
References PPTConnection::dump(), BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().
Referenced by CmdClient::dump().
Here is the call graph for this function:
int PPTConnection::readBuffer | ( | char * | buffer, | |
unsigned int | buffer_size | |||
) | [protected, virtual, inherited] |
read a buffer of data from the socket
buffer | buffer to store the data received from the socket in | |
buffer_size | max size of the data to be received |
Definition at line 414 of file PPTConnection.cc.
References Connection::_mySock, and Socket::receive().
Referenced by PPTConnection::readBufferNonBlocking(), and PPTConnection::receive().
Here is the call graph for this function:
int PPTConnection::readBufferNonBlocking | ( | char * | inBuff | ) | [protected, virtual, inherited] |
read a buffer of data from the socket without blocking
Try to read a buffer of data without blocking. We will try _timeout times, waiting 1000 milliseconds between each try. The variable _timeout is passed into the constructor.
inBuff | buffer to store the data into |
Definition at line 600 of file PPTConnection.cc.
References Connection::getSocket(), Socket::getSocketDescriptor(), PPT_PROTOCOL_BUFFER_SIZE, and PPTConnection::readBuffer().
Referenced by initConnection().
Here is the call graph for this function:
void PPTConnection::send | ( | const string & | buffer | ) | [protected, virtual, inherited] |
sends the buffer to the socket
the buffer includes the length, extensions, data, whatever is to be sent
buffer | data buffer to send to the socket |
Implements Connection.
Definition at line 179 of file PPTConnection.cc.
References Connection::_mySock, Socket::send(), and Socket::sync().
Referenced by CmdClient::executeCommand(), initConnection(), PPTConnection::sendChunk(), PPTConnection::sendExit(), and PPTConnection::sendExtensions().
Here is the call graph for this function:
void PPTConnection::send | ( | const string & | buffer, | |
map< string, string > & | extensions | |||
) | [virtual, inherited] |
Send a message to the server.
Sends the specified message buffer to the server followed by a buffer of length 0 to signify the end of the message
A buffer sent to the server will follow the following form:
Chunked-Body = chunk-extensions chunk last-chunk chunk-extensions= chunk-size 'x' *( chunk-ext-name [ "=" chunk-ext-val ] ; chunk = chunk-size 'd' chunk-data chunk-size = 4HEX last-chunk = 4("0") d chunk-ext-name = token chunk-ext-val = token | quoted-string chunk-data = chunk-size(OCTET)
If there are extensions then they are sent first. The length of the extensions is sent first, followed by the character 'x', and then the extensions in the format name[=value];
Then the buffer itself is sent. The length of the buffer is sent followed by the character 'd' signifying data is being transmitted.
if the buffer is empty then this represents the last chunk
buffer | buffer of data to send | |
extensions | list of name/value pairs sent |
Implements Connection.
Definition at line 90 of file PPTConnection.cc.
References PPTConnection::sendChunk().
Here is the call graph for this function:
void PPTConnection::sendChunk | ( | const string & | buffer, | |
map< string, string > & | extensions | |||
) | [protected, virtual, inherited] |
Send a chunk to the server.
A chunk is either the chunk with the data or the last-chunk
buffer | The data buffer to send | |
extensions | name/value pairs to send |
Implements Connection.
Definition at line 126 of file PPTConnection.cc.
References PPTConnection::send(), and PPTConnection::sendExtensions().
Referenced by PPTConnection::send().
Here is the call graph for this function:
void PPTConnection::read_extensions | ( | map< string, string > & | extensions, | |
const string & | xstr | |||
) | [protected, virtual, inherited] |
the string passed are extensions, read them and store the name/value pairs into the passed map
It has already been determined that extensions were read in the chunk. Deconstruct the name/value pairs and store them into the map passed. Each extension ends with a semicolon.
extensions | map to store the name/value pairs in | |
xstr | string of extensions in the form *(name[=value];) |
Definition at line 543 of file PPTConnection.cc.
Referenced by PPTConnection::receive().
void PPTConnection::receive | ( | ostream & | strm, | |
unsigned short | len | |||
) | [protected, virtual, inherited] |
receive from the socket the number of bytes specified until done
This method receives data from the socket until there is nothing more to be read
strm | output stream to write what is received to | |
len | number of bytes remaining to be read |
Definition at line 501 of file PPTConnection.cc.
References PPT_PROTOCOL_BUFFER_SIZE, and PPTConnection::readBuffer().
Referenced by CmdClient::executeCommand(), and PPTConnection::receive().
Here is the call graph for this function:
bool PPTConnection::receive | ( | map< string, string > & | extensions, | |
ostream * | strm = 0 | |||
) | [virtual, inherited] |
receive a chunk of either extensions into the specified map or data into the specified stream
This receive will read a chunk of information from the socket and determine if what is read are extensions, where they are stored in the extensions map passed, or data, which is written to the specified stream
The first 4 bytes is the length of the information that was passed. The 5th character is either the character 'x', signifying that extensions were sent, or 'd', signifying that data was sent.
extensions | map to store the name/value paris into | |
strm | output stream to write the received data into |
Implements Connection.
Definition at line 435 of file PPTConnection.cc.
References Connection::_out, PPT_PROTOCOL_BUFFER_SIZE, PPTConnection::read_extensions(), PPTConnection::readBuffer(), and PPTConnection::receive().
Here is the call graph for this function:
virtual string PPTConnection::exit | ( | ) | [inline, virtual, inherited] |
Implements Connection.
Definition at line 72 of file PPTConnection.h.
References PPTProtocol::PPT_EXIT_NOW.
void PPTConnection::sendExtensions | ( | map< string, string > & | extensions | ) | [virtual, inherited] |
send the specified extensions
extensions | name/value paris to be sent |
Implements Connection.
Definition at line 147 of file PPTConnection.cc.
References PPTConnection::send().
Referenced by PPTConnection::sendChunk().
Here is the call graph for this function:
void PPTConnection::sendExit | ( | ) | [virtual, inherited] |
Send the exit token as an extension.
Implements Connection.
Definition at line 110 of file PPTConnection.cc.
References PPTProtocol::PPT_EXIT_NOW, and PPTConnection::send().
Referenced by closeConnection().
Here is the call graph for this function:
virtual Socket* Connection::getSocket | ( | ) | [inline, virtual, inherited] |
Definition at line 77 of file Connection.h.
References Connection::_mySock.
Referenced by PPTConnection::readBufferNonBlocking().
virtual bool Connection::isConnected | ( | ) | [inline, virtual, inherited] |
Definition at line 82 of file Connection.h.
References Connection::_mySock, and Socket::isConnected().
Referenced by CmdClient::isConnected().
Here is the call graph for this function:
virtual void Connection::setOutputStream | ( | ostream * | strm | ) | [inline, virtual, inherited] |
virtual ostream* Connection::getOutputStream | ( | ) | [inline, virtual, inherited] |
virtual void Connection::brokenPipe | ( | ) | [inline, virtual, inherited] |
Definition at line 98 of file Connection.h.
References Connection::_brokenPipe.
Referenced by CmdClient::brokenPipe().
Socket* Connection::_mySock [protected, inherited] |
Definition at line 50 of file Connection.h.
Referenced by PPTServer::closeConnection(), closeConnection(), Connection::dump(), Connection::getSocket(), PPTServer::initConnection(), Connection::isConnected(), PPTClient(), PPTConnection::readBuffer(), PPTConnection::send(), and ~PPTClient().
ostream* Connection::_out [protected, inherited] |
Definition at line 51 of file Connection.h.
Referenced by Connection::dump(), Connection::getOutputStream(), PPTConnection::receive(), and Connection::setOutputStream().
bool Connection::_brokenPipe [protected, inherited] |
Definition at line 52 of file Connection.h.
Referenced by Connection::brokenPipe(), closeConnection(), and Connection::dump().