|
OpenCBDC Transaction Processor
|
Wrapper for a TCP socket. More...
#include <tcp_socket.hpp>


Public Member Functions | |
| tcp_socket ()=default | |
| Constructs an empty, unconnected TCP socket. | |
| ~tcp_socket () override | |
| tcp_socket (const tcp_socket &)=delete | |
| auto | operator= (const tcp_socket &) -> tcp_socket &=delete |
| tcp_socket (tcp_socket &&)=delete | |
| auto | operator= (tcp_socket &&) -> tcp_socket &=delete |
| auto | connect (const endpoint_t &ep) -> bool |
| Attempts to connect to the given endpoint. | |
| auto | connect (const ip_address &remote_address, port_number_t remote_port) -> bool |
| Attempts to connect to the given remote address/port combination. | |
| auto | send (const buffer &pkt) const -> bool |
| Sends the given packet to the remote host. | |
| template<typename T > | |
| auto | send (const T &data) const -> bool |
| Serialize the data and transmit it in a packet to the remote host. | |
| auto | receive (buffer &pkt) const -> bool |
| Attempts to receive a packet from the remote host this function will block until there is data ready to receive or an error occurs. | |
| void | disconnect () |
| Closes the connection with the remote host and unblocks any blocking calls to this socket. | |
| auto | reconnect () -> bool |
| Reconnects to the previously connected endpoint. | |
| auto | connected () const -> bool |
| Returns whether the socket successfully connected to an endpoint. | |
Public Member Functions inherited from cbdc::network::socket | |
| socket (const socket &)=delete | |
| auto | operator= (const socket &) -> socket &=delete |
| socket (socket &&)=delete | |
| auto | operator= (socket &&) -> socket &=delete |
| virtual | ~socket ()=default |
Wrapper for a TCP socket.
Manages a raw UNIX TCP socket. Handles sending and receiving discrete packets by providing a protocol for determining packet boundaries. Sends the size of the packet before the packet data. When receiving, reads the packet size and returns a discrete packet once the expected size is read in full.
Definition at line 24 of file tcp_socket.hpp.
|
default |
Constructs an empty, unconnected TCP socket.
|
override |
Definition at line 56 of file tcp_socket.cpp.
References disconnect().

|
delete |
|
delete |
| auto cbdc::network::tcp_socket::connect | ( | const endpoint_t & | ep | ) | -> bool |
Attempts to connect to the given endpoint.
| ep | the endpoint to which this socket should connect |
Definition at line 13 of file tcp_socket.cpp.
| auto cbdc::network::tcp_socket::connect | ( | const ip_address & | remote_address, |
| port_number_t | remote_port ) -> bool |
Attempts to connect to the given remote address/port combination.
| remote_address | the IP address of the remote endpoint |
| remote_port | the port number of the remote endpoint |
Definition at line 17 of file tcp_socket.cpp.
|
nodiscard |
Returns whether the socket successfully connected to an endpoint.
Definition at line 131 of file tcp_socket.cpp.
| void cbdc::network::tcp_socket::disconnect | ( | ) |
Closes the connection with the remote host and unblocks any blocking calls to this socket.
Definition at line 47 of file tcp_socket.cpp.
Referenced by ~tcp_socket().
|
delete |
|
delete |
|
nodiscard |
Attempts to receive a packet from the remote host this function will block until there is data ready to receive or an error occurs.
| pkt | the packet to receive into |
Definition at line 90 of file tcp_socket.cpp.
| auto cbdc::network::tcp_socket::reconnect | ( | ) | -> bool |
Reconnects to the previously connected endpoint.
If connect was never called before, returns an error. Disconnects any previous endpoint before re-connecting.
Definition at line 123 of file tcp_socket.cpp.
|
nodiscard |
Sends the given packet to the remote host.
| pkt | the packet to send. |
Definition at line 60 of file tcp_socket.cpp.
Referenced by send().
|
inlinenodiscard |
Serialize the data and transmit it in a packet to the remote host.
| data | data to serialize and send. |
Definition at line 58 of file tcp_socket.hpp.
References cbdc::make_buffer(), and send().
