#include <TcpHelperClasses.h>
|
asio::ip::tcp::socket & | socket () |
|
void | startReceive () |
|
void | cancel () |
|
void | close () |
|
void | closeNoWait () |
|
void | waitOnClose () |
|
bool | isReceiving () const |
|
void | setDataCall (std::function< size_t(TcpConnection::pointer, const char *, size_t)> dataFunc) |
|
void | setErrorCall (std::function< bool(TcpConnection::pointer, const std::error_code &)> errorFunc) |
|
void | setLoggingFunction (std::function< void(int loglevel, const std::string &logMessage)> logFunc) |
|
size_t | send (const void *buffer, size_t dataLength) |
|
size_t | send (const std::string &dataString) |
|
size_t | receive (void *buffer, size_t maxDataSize) |
|
template<typename Process > |
void | send_async (const void *buffer, size_t dataLength, Process callback) |
|
template<typename Process > |
void | async_receive (void *buffer, size_t dataLength, Process callback) |
|
void | async_receive (std::function< void(TcpConnection::pointer, const char *buffer, size_t dataLength, const std::error_code &error)> callback) |
|
bool | isConnected () const |
|
bool | waitUntilConnected (std::chrono::milliseconds timeOut) |
|
int | getIdentifier () const |
|
|
static pointer | create (asio::io_context &io_context, const std::string &connection, const std::string &port, size_t bufferSize=10192) |
|
static pointer | create (asio::io_context &io_context, size_t bufferSize) |
|
tcp socket generation for a receiving server
◆ connection_state_t
enum helics::tcp::TcpConnection::connection_state_t |
|
strong |
enumeration of the possible states of a connection
◆ async_receive() [1/2]
void helics::tcp::TcpConnection::async_receive |
( |
std::function< void(TcpConnection::pointer, const char *buffer, size_t dataLength, const std::error_code &error)> |
callback | ) |
|
|
inline |
perform an asynchronous receive operation
- Parameters
-
callback | the callback function to execute when data has been received with signature void(TcpConnection::pointer, const char *buffer, size_t dataLength, const std::error_code &error) |
References error.
◆ async_receive() [2/2]
template<typename Process >
void helics::tcp::TcpConnection::async_receive |
( |
void * |
buffer, |
|
|
size_t |
dataLength, |
|
|
Process |
callback |
|
) |
| |
|
inline |
perform an asynchronous receive operation
- Parameters
-
buffer | the data to send |
dataLength | the length of the data |
callback | a callback function of the form void handler( const std::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes received. ); |
◆ cancel()
void helics::tcp::TcpConnection::cancel |
( |
| ) |
|
|
inline |
cancel ongoing socket operations
◆ close()
void helics::tcp::TcpConnection::close |
( |
| ) |
|
◆ closeNoWait()
void helics::tcp::TcpConnection::closeNoWait |
( |
| ) |
|
perform the close actions but don't wait for them to be processed
◆ create()
static pointer helics::tcp::TcpConnection::create |
( |
asio::io_context & |
io_context, |
|
|
size_t |
bufferSize |
|
) |
| |
|
inlinestatic |
create an RxConnection object using the specified context and bufferSize
◆ getIdentifier()
int helics::tcp::TcpConnection::getIdentifier |
( |
| ) |
const |
|
inline |
get the id code for the socket
◆ isConnected()
bool helics::tcp::TcpConnection::isConnected |
( |
| ) |
const |
|
inline |
◆ isReceiving()
bool helics::tcp::TcpConnection::isReceiving |
( |
| ) |
const |
|
inline |
check if the connection is receiving data
◆ receive()
size_t helics::tcp::TcpConnection::receive |
( |
void * |
buffer, |
|
|
size_t |
maxDataSize |
|
) |
| |
do a blocking receive on the socket
- Exceptions
-
std::system_error | on failure |
- Returns
- the number of bytes received
◆ send() [1/2]
size_t helics::tcp::TcpConnection::send |
( |
const std::string & |
dataString | ) |
|
send a string
- Exceptions
-
std::system_error | on failure |
References send().
◆ send() [2/2]
size_t helics::tcp::TcpConnection::send |
( |
const void * |
buffer, |
|
|
size_t |
dataLength |
|
) |
| |
◆ send_async()
template<typename Process >
void helics::tcp::TcpConnection::send_async |
( |
const void * |
buffer, |
|
|
size_t |
dataLength, |
|
|
Process |
callback |
|
) |
| |
|
inline |
perform an asynchronous send operation
- Parameters
-
buffer | the data to send |
dataLength | the length of the data |
callback | a callback function of the form void handler( const std::error_code& error, // Result of operation. std::size_t bytes_transferred // Number of bytes received. ); |
◆ setDataCall()
void helics::tcp::TcpConnection::setDataCall |
( |
std::function< size_t(TcpConnection::pointer, const char *, size_t)> |
dataFunc | ) |
|
set the callback for the data object
◆ setErrorCall()
void helics::tcp::TcpConnection::setErrorCall |
( |
std::function< bool(TcpConnection::pointer, const std::error_code &)> |
errorFunc | ) |
|
set the callback for an error
◆ setLoggingFunction()
void helics::tcp::TcpConnection::setLoggingFunction |
( |
std::function< void(int loglevel, const std::string &logMessage)> |
logFunc | ) |
|
◆ socket()
asio::ip::tcp::socket& helics::tcp::TcpConnection::socket |
( |
| ) |
|
|
inline |
get the underlying socket object
◆ startReceive()
void helics::tcp::TcpConnection::startReceive |
( |
| ) |
|
start the receiving loop
References data.
◆ waitOnClose()
void helics::tcp::TcpConnection::waitOnClose |
( |
| ) |
|
wait on the closing actions
◆ waitUntilConnected()
bool helics::tcp::TcpConnection::waitUntilConnected |
( |
std::chrono::milliseconds |
timeOut | ) |
|
wait until the socket has finished the connection process
- Parameters
-
timeOut | the number of ms to wait for the connection process to finish (<0) for no limit |
- Returns
- true if connected, false if the timeout was reached
References isConnected().
Referenced by send().
The documentation for this class was generated from the following files: