Class nebula::drivers::connections::TcpSocket
ClassList > nebula > drivers > connections > TcpSocket
A wrapper around a TCP socket (AF_INET, SOCK_STREAM). Supports both client and server functionality (though server part not fully shown here).
#include <tcp.hpp>
Classes
| Type | Name |
|---|---|
| class | Builder |
Public Functions
| Type | Name |
|---|---|
| TcpSocket (const TcpSocket &) = delete |
|
| TcpSocket (TcpSocket && other) noexcept |
|
| TcpSocket & | operator= (const TcpSocket &) = delete |
| TcpSocket & | operator= (TcpSocket &&) = delete |
| std::vector< uint8_t > | receive (size_t n, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) Receive up to n bytes from the socket. This is a blocking call with an optional timeout. |
| std::vector< uint8_t > | receive (std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) Receive up to the configured internal buffer size. This is a blocking call with an optional timeout. |
| void | send (const std::vector< uint8_t > & data) Send data to the connected target. Handles partial sends by retrying until all data is transmitted. |
Public Functions Documentation
function TcpSocket [2/3]
nebula::drivers::connections::TcpSocket::TcpSocket (
const TcpSocket &
) = delete
function TcpSocket [3/3]
inline nebula::drivers::connections::TcpSocket::TcpSocket (
TcpSocket && other
) noexcept
function operator=
TcpSocket & nebula::drivers::connections::TcpSocket::operator= (
const TcpSocket &
) = delete
function operator=
TcpSocket & nebula::drivers::connections::TcpSocket::operator= (
TcpSocket &&
) = delete
function receive [1/2]
Receive up to n bytes from the socket. This is a blocking call with an optional timeout.
inline std::vector< uint8_t > nebula::drivers::connections::TcpSocket::receive (
size_t n,
std::chrono::milliseconds timeout=std::chrono::milliseconds(0)
)
When this function throws, the socket may be in an undefined state and has to be closed and re-created by the caller before the socket can be used again.
Parameters:
nThe maximum number of bytes to receive.timeoutThe timeout duration. If 0, blocks indefinitely.
Returns:
A vector containing the received bytes. Empty if timeout. May contain fewer than n bytes if less data is available.
Exception:
- SocketError if receive fails or connection is closed.
function receive [2/2]
Receive up to the configured internal buffer size. This is a blocking call with an optional timeout.
inline std::vector< uint8_t > nebula::drivers::connections::TcpSocket::receive (
std::chrono::milliseconds timeout=std::chrono::milliseconds(0)
)
Parameters:
timeoutThe timeout duration. If 0, blocks indefinitely.
Returns:
A vector containing the received bytes. Empty if timeout.
Exception:
- SocketError if receive fails or connection is closed.
function send
Send data to the connected target. Handles partial sends by retrying until all data is transmitted.
inline void nebula::drivers::connections::TcpSocket::send (
const std::vector< uint8_t > & data
)
When this function throws, the socket may be in an undefined state and has to be closed and re-created by the caller before the socket can be used again.
Parameters:
dataThe data to send
Exception:
- SocketError if send fails
The documentation for this class was generated from the following file src/nebula_core/nebula_core_hw_interfaces/include/nebula_core_hw_interfaces/nebula_hw_interfaces_common/connections/tcp.hpp