Faspstream Manager C/C++ API
3.6.1
A C and C++ language interface to basic streaming over the fasp protocol
|
#include <FaspStreamClient.h>
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.
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.
appId | a string identifier which is unique to this application |
channel | an implementation of the FaspConnectionChannel iface |
FASPSTREAM_CPP_API FaspStreamClient::~FaspStreamClient | ( | ) |
Kills faspstream process if it is still alive. Does any remaining clean up.
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.
host | the host to connect to |
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)
log_callback | pointer 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 | ) |