![]() |
DUNE: Uniform Navigational Environment
2022.04.0
|
TCPSocket wraper for the specific usecase.
Public Member Functions | |
SafeTCPSocket (Tasks::Task *a_task, std::string a_name) | |
SafeTCPSocket (Tasks::Task *a_task, std::string a_name, TCPSocket *a_sock) | |
~SafeTCPSocket () | |
void | startListen (uint16_t a_port, Address a_address, bool reuse, int backlog) |
void | connect (Address a_address, uint16_t a_port) |
void | reconnect () |
SafeTCPSocket * | accept (std::string a_name) |
bool | poll (double timeout) |
size_t | read (uint8_t *data, size_t length) |
size_t | write (const char *data, size_t length) |
size_t | write (const uint8_t *data, size_t length) |
size_t | writeString (const std::string str) |
Public Attributes | |
Tasks::Task * | task |
TCPSocket * | sock |
std::string | name |
uint16_t | port |
Address | address |
|
inline |
Constructor for new socket.
Referenced by accept(), and Simulators::EvoSimulator::Task::onResourceAcquisition().
|
inline |
Constructor for existing socket.
|
inline |
Destructor.
References sock.
|
inline |
Accept connection from outside socket.
[in] | a_name | name of new SafeTCPSocket |
References SafeTCPSocket().
Referenced by Simulators::EvoSimulator::Task::checkSocket().
|
inline |
Connect socket to remote port.
[in] | a_address | address of remote socket |
[in] | a_port | port of remote socket |
References port.
Referenced by Simulators::EvoSimulator::Task::checkReset(), Simulators::EvoSimulator::Task::onResourceAcquisition(), and reconnect().
|
inline |
Poll socket for reading.
[in] | timeout | time it waits for socket in seconds |
Referenced by Simulators::EvoSimulator::Task::checkSocket(), Simulators::EvoSimulator::Task::transport(), and Simulators::EvoSimulator::Task::waitReply().
|
inline |
Read from socket to buffer.
[in] | data | buffer |
[in] | length | number of bytes to read |
References reconnect().
Referenced by Simulators::EvoSimulator::Task::transport(), and Simulators::EvoSimulator::Task::waitReply().
|
inline |
Attempt reconnection to saved socket address.
References connect().
Referenced by read(), write(), and writeString().
|
inline |
Socket starts listening for connection requests.
[in] | a_port | port to bind socket |
[in] | a_address | address to bind socket |
[in] | reuse | flag to allow reuse of address |
[in] | backlog | number of connections allowed |
Referenced by Simulators::EvoSimulator::Task::onResourceAcquisition().
|
inline |
Write to socket.
[in] | data | data buffer |
[in] | lenght | number of bytes to write |
References reconnect().
Referenced by Simulators::EvoSimulator::Task::transport().
|
inline |
Write to socket.
[in] | data | data buffer |
[in] | lenght | number of bytes to write |
References reconnect().
|
inline |
Write string to socket.
[in] | str | string to write |
References reconnect().
Referenced by Simulators::EvoSimulator::Task::sendSetting(), and Simulators::EvoSimulator::Task::updateState().
Address Simulators::EvoSimulator::SafeTCPSocket::address |
Address used in case of connection.
Referenced by Simulators::EvoSimulator::Task::autoAssign().
std::string Simulators::EvoSimulator::SafeTCPSocket::name |
Name of socket.
Referenced by Simulators::EvoSimulator::Task::checkSocket(), and Simulators::EvoSimulator::Task::transport().
uint16_t Simulators::EvoSimulator::SafeTCPSocket::port |
Port used in case of connection.
Referenced by connect().
TCPSocket* Simulators::EvoSimulator::SafeTCPSocket::sock |
TCP socket.
Referenced by Simulators::EvoSimulator::Task::checkSocket(), and ~SafeTCPSocket().
Tasks::Task* Simulators::EvoSimulator::SafeTCPSocket::task |
Handle to task using the wraper.