6#ifndef OPENCBDC_TX_SRC_NETWORK_TCP_SOCKET_H_
7#define OPENCBDC_TX_SRC_NETWORK_TCP_SOCKET_H_
52 [[nodiscard]]
auto send(
const buffer& pkt)
const -> bool;
58 [[nodiscard]]
auto send(
const T& data)
const ->
bool {
85 [[nodiscard]]
auto connected() const ->
bool;
90 std::atomic_bool m_connected{
false};
Buffer to store and retrieve byte data.
Generic superclass for network sockets.
Wrapper for a TCP socket.
auto send(const T &data) const -> bool
Serialize the data and transmit it in a packet to the remote host.
auto reconnect() -> bool
Reconnects to the previously connected endpoint.
tcp_socket(tcp_socket &&)=delete
auto connected() const -> bool
Returns whether the socket successfully connected to an endpoint.
auto send(const buffer &pkt) const -> bool
Sends the given packet to the remote host.
auto operator=(const tcp_socket &) -> tcp_socket &=delete
tcp_socket(const tcp_socket &)=delete
void disconnect()
Closes the connection with the remote host and unblocks any blocking calls to this socket.
auto receive(buffer &pkt) const -> bool
Attempts to receive a packet from the remote host this function will block until there is data ready ...
auto connect(const endpoint_t &ep) -> bool
Attempts to connect to the given endpoint.
tcp_socket()=default
Constructs an empty, unconnected TCP socket.
auto operator=(tcp_socket &&) -> tcp_socket &=delete
std::string ip_address
An IP addresses.
std::pair< ip_address, port_number_t > endpoint_t
[host name, port number].
unsigned short port_number_t
Port number.
auto make_buffer(const T &obj) -> std::enable_if_t< std::is_same_v< B, nuraft::ptr< nuraft::buffer > >, nuraft::ptr< nuraft::buffer > >
Serialize object into nuraft::buffer using a cbdc::nuraft_serializer.