OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
tcp_listener.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_NETWORK_TCP_LISTENER_H_
7#define OPENCBDC_TX_SRC_NETWORK_TCP_LISTENER_H_
8
9#include "tcp_socket.hpp"
10
11namespace cbdc::network {
13 class tcp_listener : public socket {
14 public:
16 tcp_listener() = default;
17 ~tcp_listener() override;
18
19 tcp_listener(const tcp_listener&) = delete;
20 auto operator=(const tcp_listener&) -> tcp_listener& = delete;
21
23 auto operator=(tcp_listener&&) -> tcp_listener& = delete;
24
29 auto listen(const ip_address& local_address, port_number_t local_port)
30 -> bool;
31
36 auto accept(tcp_socket& sock) -> bool;
37
40 void close();
41 };
42}
43
44#endif
Generic superclass for network sockets.
Definition socket.hpp:30
Listens for incoming TCP connections on a given endpoint.
tcp_listener()=default
Constructs a new tcp_listener.
auto listen(const ip_address &local_address, port_number_t local_port) -> bool
Starts the listener on the given local port and address.
tcp_listener(const tcp_listener &)=delete
tcp_listener(tcp_listener &&)=delete
auto operator=(const tcp_listener &) -> tcp_listener &=delete
void close()
Stops the listener and unblocks any blocking calls associated with this listener.
auto accept(tcp_socket &sock) -> bool
Blocks until an incoming connection is ready and populates the given socket.
auto operator=(tcp_listener &&) -> tcp_listener &=delete
Wrapper for a TCP socket.
std::string ip_address
An IP addresses.
Definition socket.hpp:15
unsigned short port_number_t
Port number.
Definition socket.hpp:17