Faspstream Manager C/C++ API  3.6.1
A C and C++ language interface to basic streaming over the fasp protocol
FaspStreamClient Class Reference

#include <FaspStreamClient.h>

Public Member Functions

FASPSTREAM_CPP_API FaspStreamClient (const std::string &appId, FaspConnectionChannel *channel=NULL)
 
FASPSTREAM_CPP_API bool connect (const std::string &host)
 
FASPSTREAM_CPP_API FaspInputStreamgetFaspInputStream ()
 
FASPSTREAM_CPP_API FaspOutputStreamgetFaspOutputStream ()
 
FASPSTREAM_CPP_API void cleanup ()
 
FASPSTREAM_CPP_API ~FaspStreamClient ()
 
FASPSTREAM_CPP_API const std::string & getUsername () const
 
FASPSTREAM_CPP_API int getMaxMemory () const
 
FASPSTREAM_CPP_API void setMaxMemory (int maxMem)
 
FASPSTREAM_CPP_API int getUdpPort () const
 
FASPSTREAM_CPP_API void setUdpPort (int port)
 
FASPSTREAM_CPP_API int getPort () const
 
FASPSTREAM_CPP_API void setPort (int tcpPort)
 
FASPSTREAM_CPP_API int getDatagramSize () const
 
FASPSTREAM_CPP_API void setDatagramSize (int size)
 
FASPSTREAM_CPP_API int getChunkSize () const
 
FASPSTREAM_CPP_API void setChunkSize (int size)
 
FASPSTREAM_CPP_API const std::string & getHostname () const
 
FASPSTREAM_CPP_API void setHostname (const std::string &name)
 
FASPSTREAM_CPP_API int getRateTarget () const
 
FASPSTREAM_CPP_API void setRateTarget (int target)
 
FASPSTREAM_CPP_API FASPSTREAM_CIPHER_TYPE getCipherType () const
 
FASPSTREAM_CPP_API void setCipherType (FASPSTREAM_CIPHER_TYPE type)
 
FASPSTREAM_CPP_API bool isLockTarget () const
 
FASPSTREAM_CPP_API void setLockTarget (bool target)
 
FASPSTREAM_CPP_API int getRateMinimum () const
 
FASPSTREAM_CPP_API void setRateMinimum (int minimum)
 
FASPSTREAM_CPP_API bool isLockMinimum () const
 
FASPSTREAM_CPP_API void setLockMinimum (bool lockMin)
 
FASPSTREAM_CPP_API FASPSTREAM_POLICY_TYPE getPolicy () const
 
FASPSTREAM_CPP_API void setPolicy (FASPSTREAM_POLICY_TYPE newPolicy)
 
FASPSTREAM_CPP_API bool isLockPolicy () const
 
FASPSTREAM_CPP_API void setLockPolicy (bool lock)
 
FASPSTREAM_CPP_API int getAggressiveness () const
 
FASPSTREAM_CPP_API void setAggressiveness (int aggressive)
 
FASPSTREAM_CPP_API const std::string & getFaspstreamPath () const
 
FASPSTREAM_CPP_API void setFaspstreamPath (const std::string &path)
 
FASPSTREAM_CPP_API int getForceSendMilliseconds () const
 
FASPSTREAM_CPP_API void setForceSendMilliseconds (int milliseconds)
 
FASPSTREAM_CPP_API void setTransferMode (FASPSTREAM_TRANSFER_MODE_TYPE transferMode)
 
FASPSTREAM_CPP_API FASPSTREAM_TRANSFER_MODE_TYPE getTransferMode () const
 
FASPSTREAM_CPP_API void setPrivateKeyFile (const std::string &privateKeyFile)
 
FASPSTREAM_CPP_API const std::string & getPrivateKeyFile () const
 
FASPSTREAM_CPP_API void setSSHUser (const std::string &sshUser)
 
FASPSTREAM_CPP_API const std::string & getSSHUser () const
 
FASPSTREAM_CPP_API void setLogDirectory (const std::string &logDirectory)
 
FASPSTREAM_CPP_API const std::string & getLogDirectory () const
 
FASPSTREAM_CPP_API void setCommandToExecute (const std::string &commandToExecute)
 
FASPSTREAM_CPP_API const std::string & getCommandToExecute () const
 
FASPSTREAM_CPP_API void setLicense (std::string commandToExecute)
 
FASPSTREAM_CPP_API std::string getLicense () const
 
FASPSTREAM_CPP_API std::vector< std::string > getCommandline () const
 
void registerLogCallback (log_callback_f log_function)
 

Detailed Description

Use the FaspStreamClient class to connect to a faspstream server and then send or receive a stream of data. Note this class does not inherit from any of the C++ std::ios stream classes, and requires the user to implement a read()/write() loop.

Constructor & Destructor Documentation

FASPSTREAM_CPP_API FaspStreamClient::FaspStreamClient ( const std::string &  appId,
FaspConnectionChannel channel = NULL 
)

Does basic initialization of client's fields, sets defaults, etc.

The channel argument is optional and is only used when you would like to share a TCP connection so that our internal code can tunnel fasp control data on the TCP connection you share.

IMPORTANT: If you use the channel argument, the channel's destructor must fire after the client's destructor. Otherwise, the background thread that does the tunneling may cause a seg fault.

Parameters
appIda string identifier which is unique to this application
channelan implementation of the FaspConnectionChannel iface
FASPSTREAM_CPP_API FaspStreamClient::~FaspStreamClient ( )

Kills faspstream process if it is still alive. Does any remaining clean up.

Member Function Documentation

FASPSTREAM_CPP_API void FaspStreamClient::cleanup ( )

IMPORTANT: You should call this before the destructor fires. If the faspstream process is still working and destructor is called, it will be killed.

Closes input and output streams and waits for faspstream process to gracefully exit.

If you shared a TCP socket for fasp control data tunneling, the background thread will be terminated, and under normal conditions, your channel's close method will be invoked.

Throws a FaspStreamException if the exit status of the faspstream process is non-zero.

FASPSTREAM_CPP_API bool FaspStreamClient::connect ( const std::string &  host)

Connect to faspstream server listening at host.

If you are sharing a TCP connection (out-of-band feature), the host argument is ignored.

Throws std::runtime_error if there is a problem starting up the faspstream process.

Parameters
hostthe host to connect to
Returns
true if faspstream was started successfully
FASPSTREAM_CPP_API int FaspStreamClient::getAggressiveness ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getChunkSize ( ) const
FASPSTREAM_CPP_API FASPSTREAM_CIPHER_TYPE FaspStreamClient::getCipherType ( ) const
FASPSTREAM_CPP_API std::vector<std::string> FaspStreamClient::getCommandline ( ) const

This method can be used to generate the command line arguments with which the faspstream child process will be invoked, it can be useful for debugging purposes but is not normally necessary.

FASPSTREAM_CPP_API const std::string& FaspStreamClient::getCommandToExecute ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getDatagramSize ( ) const
FASPSTREAM_CPP_API FaspInputStream& FaspStreamClient::getFaspInputStream ( )

Use these to get the underlying input and output streams connected to the faspstream process.

IMPORTANT: You should call these every time you try to do a read/write. We do a check each time you invoke these to ensure the faspstream is still open.

NOTE: If you are doing a "send", you need the output stream. If you are doing a "recv", you need the input stream.

FASPSTREAM_CPP_API FaspOutputStream& FaspStreamClient::getFaspOutputStream ( )
FASPSTREAM_CPP_API const std::string& FaspStreamClient::getFaspstreamPath ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getForceSendMilliseconds ( ) const
FASPSTREAM_CPP_API const std::string& FaspStreamClient::getHostname ( ) const
FASPSTREAM_CPP_API std::string FaspStreamClient::getLicense ( ) const
FASPSTREAM_CPP_API const std::string& FaspStreamClient::getLogDirectory ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getMaxMemory ( ) const
FASPSTREAM_CPP_API FASPSTREAM_POLICY_TYPE FaspStreamClient::getPolicy ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getPort ( ) const
FASPSTREAM_CPP_API const std::string& FaspStreamClient::getPrivateKeyFile ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getRateMinimum ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getRateTarget ( ) const
FASPSTREAM_CPP_API const std::string& FaspStreamClient::getSSHUser ( ) const
FASPSTREAM_CPP_API FASPSTREAM_TRANSFER_MODE_TYPE FaspStreamClient::getTransferMode ( ) const
FASPSTREAM_CPP_API int FaspStreamClient::getUdpPort ( ) const
FASPSTREAM_CPP_API const std::string& FaspStreamClient::getUsername ( ) const
FASPSTREAM_CPP_API bool FaspStreamClient::isLockMinimum ( ) const
FASPSTREAM_CPP_API bool FaspStreamClient::isLockPolicy ( ) const
FASPSTREAM_CPP_API bool FaspStreamClient::isLockTarget ( ) const
void FaspStreamClient::registerLogCallback ( log_callback_f  log_function)

Method for registering a logging callback

When a new log entry is available the function specified will be called (signature: void return, const char* argument). (Will not log if NULL, as is by default)

Parameters
log_callbackpointer to log function you have implemented

The simplest implementation of the callback might look like this:

static void log_function( char const *s ) {
  fprintf( stderr, "%s\n", s );
}

FASPSTREAM_CPP_API void FaspStreamClient::setAggressiveness ( int  aggressive)
FASPSTREAM_CPP_API void FaspStreamClient::setChunkSize ( int  size)
FASPSTREAM_CPP_API void FaspStreamClient::setCipherType ( FASPSTREAM_CIPHER_TYPE  type)
FASPSTREAM_CPP_API void FaspStreamClient::setCommandToExecute ( const std::string &  commandToExecute)
FASPSTREAM_CPP_API void FaspStreamClient::setDatagramSize ( int  size)
FASPSTREAM_CPP_API void FaspStreamClient::setFaspstreamPath ( const std::string &  path)
FASPSTREAM_CPP_API void FaspStreamClient::setForceSendMilliseconds ( int  milliseconds)
FASPSTREAM_CPP_API void FaspStreamClient::setHostname ( const std::string &  name)
FASPSTREAM_CPP_API void FaspStreamClient::setLicense ( std::string  commandToExecute)
FASPSTREAM_CPP_API void FaspStreamClient::setLockMinimum ( bool  lockMin)
FASPSTREAM_CPP_API void FaspStreamClient::setLockPolicy ( bool  lock)
FASPSTREAM_CPP_API void FaspStreamClient::setLockTarget ( bool  target)
FASPSTREAM_CPP_API void FaspStreamClient::setLogDirectory ( const std::string &  logDirectory)
FASPSTREAM_CPP_API void FaspStreamClient::setMaxMemory ( int  maxMem)
FASPSTREAM_CPP_API void FaspStreamClient::setPolicy ( FASPSTREAM_POLICY_TYPE  newPolicy)
FASPSTREAM_CPP_API void FaspStreamClient::setPort ( int  tcpPort)
FASPSTREAM_CPP_API void FaspStreamClient::setPrivateKeyFile ( const std::string &  privateKeyFile)
FASPSTREAM_CPP_API void FaspStreamClient::setRateMinimum ( int  minimum)
FASPSTREAM_CPP_API void FaspStreamClient::setRateTarget ( int  target)
FASPSTREAM_CPP_API void FaspStreamClient::setSSHUser ( const std::string &  sshUser)
FASPSTREAM_CPP_API void FaspStreamClient::setTransferMode ( FASPSTREAM_TRANSFER_MODE_TYPE  transferMode)
FASPSTREAM_CPP_API void FaspStreamClient::setUdpPort ( int  port)

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