qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
accept.h
Go to the documentation of this file.
1
24
25#ifndef QB_IO_TRANSPORT_ACCEPT_H_
26#define QB_IO_TRANSPORT_ACCEPT_H_
27#include "../tcp/listener.h"
28
29namespace qb::io::transport {
30
44class accept {
46 io::tcp::socket _accepted_io;
47
48public:
50 constexpr bool is_secure() const noexcept { return false; }
53
56
62 transport() noexcept {
63 return _io;
64 }
65
74 std::size_t
75 read() noexcept {
76 if (_io.accept(_accepted_io) == io::SocketStatus::Done)
77 return static_cast<std::size_t>(_accepted_io.native_handle());
78 return static_cast<std::size_t>(-1);
79 }
80
88 void
89 flush(std::size_t) noexcept {
90 _accepted_io.release_handle();
91 }
92
99 void
100 eof() const noexcept {}
101
108 void
109 close() noexcept {
110 _io.close();
111 }
112
122 return _accepted_io;
123 }
124};
125
126} // namespace qb::io::transport
127
128#endif // QB_IO_TRANSPORT_ACCEPT_H_
Class implementing a TCP listener for accepting incoming connections.
Definition listener.h:42
Class implementing TCP socket functionality for reliable, stream-oriented communication.
Definition socket.h:43
Connection acceptance transport for TCP connections.
Definition accept.h:44
void close() noexcept
Close the listener.
Definition accept.h:109
void eof() const noexcept
End-of-file handling (no-op)
Definition accept.h:100
std::size_t read() noexcept
Accept a new connection.
Definition accept.h:75
io::tcp::socket & getAccepted()
Get the accepted socket.
Definition accept.h:121
constexpr bool is_secure() const noexcept
Indicates that this transport implementation is not secure.
Definition accept.h:50
io::tcp::listener & transport() noexcept
Get the underlying TCP listener.
Definition accept.h:62
io::tcp::socket socket_type
Type of the accepted socket.
Definition accept.h:55
io::tcp::listener transport_io_type
Type of the underlying transport I/O.
Definition accept.h:52
void flush(std::size_t) noexcept
Release the accepted socket handle.
Definition accept.h:89
Implementation of a TCP listener for the QB IO library.