bes Updated for version 3.20.13
PPTServer Class Reference
Collaboration diagram for PPTServer:
Collaboration graph

Public Member Functions

virtual void brokenPipe ()
 
void closeConnection () override
 
void decr_num_children ()
 
void dump (std::ostream &strm) const override
 dumps information about this object
 
virtual std::string exit ()
 
int get_num_children () const
 
virtual std::ostream * getOutputStream ()
 
virtual unsigned int getRecvChunkSize ()
 
virtual unsigned int getSendChunkSize ()
 
virtual SocketgetSocket ()
 
void incr_num_children ()
 
void initConnection () override
 
virtual bool isConnected ()
 
 PPTServer (ServerHandler *handler, SocketListener *listener, bool isSecure)
 
virtual bool receive (std::map< std::string, std::string > &extensions, std::ostream *strm=0)
 receive a chunk of either extensions into the specified map or data into the specified stream
 
virtual void send (const std::string &buffer, std::map< std::string, std::string > &extensions)
 Send a message to the server.
 
virtual void sendExit ()
 Send the exit token as an extension.
 
virtual void sendExtensions (std::map< std::string, std::string > &extensions)
 send the specified extensions
 
virtual void setOutputStream (std::ostream *strm)
 

Protected Member Functions

virtual void read_extensions (std::map< std::string, std::string > &extensions, const std::string &xstr)
 the string passed are extensions, read them and store the name/value pairs into the passed map
 
virtual int readBuffer (char *inBuff, const unsigned int buff_size)
 read a buffer of data from the socket
 
virtual int readBufferNonBlocking (char *inBuff, const int buff_size)
 read a buffer of data from the socket without blocking
 
virtual void send (const std::string &buffer)
 sends the buffer to the socket
 

Protected Attributes

bool _brokenPipe
 
Socket_mySock
 
std::ostream * _out
 

Detailed Description

Definition at line 42 of file PPTServer.h.

Constructor & Destructor Documentation

◆ PPTServer()

PPTServer::PPTServer ( ServerHandler handler,
SocketListener listener,
bool  isSecure 
)

Definition at line 67 of file PPTServer.cc.

Member Function Documentation

◆ brokenPipe()

virtual void Connection::brokenPipe ( )
inlinevirtualinherited

Definition at line 92 of file Connection.h.

◆ closeConnection()

void PPTServer::closeConnection ( )
overridevirtual

Implements PPTConnection.

Definition at line 170 of file PPTServer.cc.

◆ decr_num_children()

void PPTServer::decr_num_children ( )
inline

Definition at line 64 of file PPTServer.h.

◆ dump()

void PPTServer::dump ( std::ostream &  strm) const
overridevirtual

dumps information about this object

Displays the pointer value of this instance

Parameters
strmC++ i/o stream to dump the information to

Reimplemented from PPTConnection.

Definition at line 278 of file PPTServer.cc.

◆ exit()

virtual std::string PPTConnection::exit ( )
inlinevirtualinherited

Implements Connection.

Definition at line 78 of file PPTConnection.h.

◆ get_num_children()

int PPTServer::get_num_children ( ) const
inline

Definition at line 62 of file PPTServer.h.

◆ getOutputStream()

virtual std::ostream * Connection::getOutputStream ( )
inlinevirtualinherited

Definition at line 87 of file Connection.h.

◆ getRecvChunkSize()

unsigned int PPTConnection::getRecvChunkSize ( )
virtualinherited

Implements Connection.

Definition at line 456 of file PPTConnection.cc.

◆ getSendChunkSize()

unsigned int PPTConnection::getSendChunkSize ( )
virtualinherited

Implements Connection.

Definition at line 461 of file PPTConnection.cc.

◆ getSocket()

virtual Socket * Connection::getSocket ( )
inlinevirtualinherited

Definition at line 72 of file Connection.h.

◆ incr_num_children()

void PPTServer::incr_num_children ( )
inline

Definition at line 63 of file PPTServer.h.

◆ initConnection()

void PPTServer::initConnection ( )
overridevirtual

Using the info passed into the SocketLister, wait for an inbound request (see SocketListener::accept()). When one is found, do the welcome message stuff (welcomeClient()) and then pass this to the handler's handle method. Note that this is a pointer to a PPTServer which is a kind of Connection.

Implements PPTConnection.

Definition at line 140 of file PPTServer.cc.

◆ isConnected()

virtual bool Connection::isConnected ( )
inlinevirtualinherited

Definition at line 77 of file Connection.h.

◆ read_extensions()

void PPTConnection::read_extensions ( std::map< std::string, std::string > &  extensions,
const std::string &  xstr 
)
protectedvirtualinherited

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.

Parameters
extensionsmap to store the name/value pairs in
xstrstring of extensions in the form *(name[=value];)

Definition at line 373 of file PPTConnection.cc.

◆ readBuffer()

int PPTConnection::readBuffer ( char *  buffer,
const unsigned int  buffer_size 
)
protectedvirtualinherited

read a buffer of data from the socket

Parameters
bufferbuffer to store the data received from the socket in
buffer_sizemax size of the data to be received
Returns
number of bytes actually read

Definition at line 209 of file PPTConnection.cc.

◆ readBufferNonBlocking()

int PPTConnection::readBufferNonBlocking ( char *  inBuff,
const int  buffer_size 
)
protectedvirtualinherited

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.

Parameters
inBuffbuffer to store the data into
buffer_sizethe size of the passed buffer
Returns
number of bytes read in, -1 if failed to read anything

Definition at line 421 of file PPTConnection.cc.

◆ receive()

bool PPTConnection::receive ( std::map< std::string, std::string > &  extensions,
std::ostream *  strm = 0 
)
virtualinherited

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 7 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.

Parameters
extensionsmap to store the name/value paris into
strmoutput stream to write the received data into
Returns
true if what was received is the last chunk, false otherwise

Implements Connection.

Definition at line 258 of file PPTConnection.cc.

◆ send() [1/2]

void PPTConnection::send ( const std::string &  buffer)
protectedvirtualinherited

sends the buffer to the socket

the buffer includes the length, extensions, data, whatever is to be sent

Parameters
bufferdata buffer to send to the socket

Implements Connection.

Definition at line 190 of file PPTConnection.cc.

◆ send() [2/2]

void PPTConnection::send ( const std::string &  buffer,
std::map< std::string, std::string > &  extensions 
)
virtualinherited

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 = 8HEX
last-chunk = 7("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

Parameters
bufferbuffer of data to send
extensionslist of name/value pairs sent

Implements Connection.

Definition at line 109 of file PPTConnection.cc.

◆ sendExit()

void PPTConnection::sendExit ( )
virtualinherited

Send the exit token as an extension.

Implements Connection.

Definition at line 125 of file PPTConnection.cc.

◆ sendExtensions()

void PPTConnection::sendExtensions ( std::map< std::string, std::string > &  extensions)
virtualinherited

send the specified extensions

Parameters
extensionsname/value paris to be sent

Implements Connection.

Definition at line 162 of file PPTConnection.cc.

◆ setOutputStream()

virtual void Connection::setOutputStream ( std::ostream *  strm)
inlinevirtualinherited

Definition at line 83 of file Connection.h.

Member Data Documentation

◆ _brokenPipe

bool Connection::_brokenPipe
protectedinherited

Definition at line 47 of file Connection.h.

◆ _mySock

Socket* Connection::_mySock
protectedinherited

Definition at line 45 of file Connection.h.

◆ _out

std::ostream* Connection::_out
protectedinherited

Definition at line 46 of file Connection.h.


The documentation for this class was generated from the following files: