qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::io::transport::accept Class Reference

Connection acceptance transport for TCP connections. More...

#include <accept.h>

Inheritance diagram for qb::io::transport::accept:

Public Types

using transport_io_type = io::tcp::listener
 Type of the underlying transport I/O.
using socket_type = io::tcp::socket
 Type of the accepted socket.

Public Member Functions

constexpr bool is_secure () const noexcept
 Indicates that this transport implementation is not secure.
io::tcp::listenertransport () noexcept
 Get the underlying TCP listener.
std::size_t read () noexcept
 Accept a new connection.
void flush (std::size_t) noexcept
 Release the accepted socket handle.
void eof () const noexcept
 End-of-file handling (no-op)
void close () noexcept
 Close the listener.
io::tcp::socketgetAccepted ()
 Get the accepted socket.

Detailed Description

Connection acceptance transport for TCP connections.

This class implements a transport layer specific to accepting incoming TCP connections. It wraps a qb::io::tcp::listener and is primarily used as the IO type (_IO_) for stream classes (like qb::io::istream) when building acceptor components (e.g., qb::io::async::tcp::acceptor).

Its read() method attempts to accept a new connection via the listener, and getAccepted() provides access to the newly accepted qb::io::tcp::socket.

Member Function Documentation

◆ transport()

io::tcp::listener & qb::io::transport::accept::transport ( )
inlinenoexcept

Get the underlying TCP listener.

Returns
Reference to the TCP listener

◆ read()

std::size_t qb::io::transport::accept::read ( )
inlinenoexcept

Accept a new connection.

Returns
Native handle of the accepted socket, or -1 on failure

Attempts to accept a new connection. If successful, returns the native handle of the accepted socket which can be used for further communication.

◆ flush()

void qb::io::transport::accept::flush ( std::size_t )
inlinenoexcept

Release the accepted socket handle.

Parameters
Unusedparameter

Releases the handle of the last accepted socket to prevent it from being closed when the socket object is destroyed.

◆ eof()

void qb::io::transport::accept::eof ( ) const
inlinenoexcept

End-of-file handling (no-op)

This is a placeholder method with no implementation as connection acceptance doesn't have an EOF concept.

◆ close()

void qb::io::transport::accept::close ( )
inlinenoexcept

Close the listener.

Closes the underlying TCP listener, stopping the acceptance of new connections.

◆ getAccepted()

io::tcp::socket & qb::io::transport::accept::getAccepted ( )
inline

Get the accepted socket.

Returns
Reference to the last accepted socket

Returns a reference to the socket object representing the last accepted connection.