qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
listener.h
Go to the documentation of this file.
1
24
25#include "socket.h"
26
27#ifndef QB_IO_TCP_LISTENER_H_
28#define QB_IO_TCP_LISTENER_H_
29
30namespace qb::io::tcp {
31
42class QB_API listener : private io::socket {
43public:
45 constexpr static bool is_secure() noexcept { return false; }
46
47 // Methods inherited from the base socket (made public via using-declarations)
48 using qb::io::socket::close;
49 using qb::io::socket::get_optval;
50 using qb::io::socket::is_open;
51 using qb::io::socket::local_endpoint;
52 using qb::io::socket::native_handle;
53 using qb::io::socket::peer_endpoint;
54 using qb::io::socket::release_handle;
55 using qb::io::socket::set_nonblocking;
56 using qb::io::socket::set_optval;
57 using qb::io::socket::test_nonblocking;
58
67 int listen(io::endpoint const &ep) noexcept;
68
76 int listen(io::uri const &uri) noexcept;
77
85 int listen_v4(uint16_t port, std::string const &host = "0.0.0.0") noexcept;
86
94 int listen_v6(uint16_t port, std::string const &host = "::") noexcept;
95
104 int listen_un(std::string const &path) noexcept;
105
114 tcp::socket accept() const noexcept;
115
124 int accept(tcp::socket &sock) const noexcept;
125
131 int disconnect() const noexcept;
132};
133
134} // namespace qb::io::tcp
135
136#endif // QB_IO_TCP_LISTENER_H_
Class implementing a TCP listener for accepting incoming connections.
Definition listener.h:42
tcp::socket accept() const noexcept
Accept a new incoming TCP connection and return it as a new tcp::socket.
static constexpr bool is_secure() noexcept
Indicates that this socket implementation is not secure.
Definition listener.h:45
int listen_v6(uint16_t port, std::string const &host="::") noexcept
Start listening on a specific IPv6 address and port.
int disconnect() const noexcept
Disconnect the listener socket, stopping it from accepting new connections.
int listen_un(std::string const &path) noexcept
Start listening on a Unix domain socket.
int listen_v4(uint16_t port, std::string const &host="0.0.0.0") noexcept
Start listening on a specific IPv4 address and port.
int listen(io::uri const &uri) noexcept
Start listening on an endpoint specified by a URI.
int listen(io::endpoint const &ep) noexcept
Start listening on a specific local endpoint.
Class implementing TCP socket functionality for reliable, stream-oriented communication.
Definition socket.h:43
Class for parsing, manipulating, and representing URIs.
Definition uri.h:181
Implementation of TCP sockets for the QB IO library.