qb
2.0.0.0
C++17 Actor Framework
|
Protocol for handling the acceptance of new network connections. More...
#include <accept.h>
Public Types | |
using | message = _Socket |
Type alias for the socket type. |
Public Member Functions | |
accept ()=delete | |
Default constructor is deleted as an I/O component reference is required. | |
accept (_IO_ &io) noexcept | |
Constructor with I/O reference. | |
std::size_t | getMessageSize () noexcept final |
Checks if a new connection is available to be processed. | |
void | onMessage (std::size_t) noexcept final |
Processes a newly accepted connection. | |
void | reset () noexcept final |
Resets the protocol state. | |
Public Member Functions inherited from qb::io::async::IProtocol | |
virtual | ~IProtocol ()=default |
Virtual destructor. | |
bool | ok () const noexcept |
Checks if the protocol is in a valid operational state. | |
void | not_ok () noexcept |
Marks the protocol as being in an invalid or non-operational state. | |
void | set_should_flush (bool should_flush) noexcept |
Sets the flag indicating whether the protocol should flush the input buffer after processing a message. | |
bool | should_flush () const noexcept |
Gets the flag indicating whether the protocol should flush the input buffer after processing a message. |
Additional Inherited Members | |
Protected Member Functions inherited from qb::io::async::AProtocol< _IO_ > | |
AProtocol ()=delete | |
Default constructor is deleted to ensure an I/O component is always associated. | |
AProtocol (_IO_ &io) noexcept | |
Constructor that associates the protocol with an I/O component. | |
virtual | ~AProtocol ()=default |
Virtual destructor. | |
Protected Attributes inherited from qb::io::async::AProtocol< _IO_ > | |
_IO_ & | _io |
Reference to the I/O component instance that this protocol is associated with. |
Protocol for handling the acceptance of new network connections.
This template class implements the AProtocol interface specifically for connection-accepting components (like qb::io::async::tcp::acceptor). Its primary role is to detect when a new connection has been successfully accepted by the underlying listener socket and to deliver the new connection's socket (as _Socket type) to the I/O component.
_IO_ | The I/O component type that uses this protocol (typically an acceptor class). It must provide a getAccepted() method returning a reference to the newly accepted socket. |
_Socket | The type of socket that represents the newly accepted connection (e.g., qb::io::tcp::socket). |
using qb::io::protocol::accept< _IO_, _Socket >::message = _Socket |
Type alias for the socket type.
The type of message this protocol produces, which is the accepted socket itself.
|
inlinenoexcept |
Constructor with I/O reference.
io | Reference to the I/O component (e.g., an acceptor) that will use this protocol. |
|
inlinefinalvirtualnoexcept |
Checks if a new connection is available to be processed.
This method determines if a new connection has been accepted by checking if the socket obtained from this->_io.getAccepted() is currently open.
Implements qb::io::async::AProtocol< _IO_ >.
|
inlinefinalvirtualnoexcept |
Processes a newly accepted connection.
This method is called when getMessageSize() returns a non-zero value (i.e., an open socket was found). It then calls the I/O component's on() handler, passing the newly accepted socket (obtained via this->_io.getAccepted()) by moving it.
size | Ignored parameter (required by AProtocol interface, but its value is not used here as getMessageSize() for this protocol effectively returns a boolean status). |
Implements qb::io::async::AProtocol< _IO_ >.
|
inlinefinalvirtualnoexcept |
Resets the protocol state.
This protocol is stateless regarding message parsing (it only checks socket status), so this method is a no-op.
Implements qb::io::async::AProtocol< _IO_ >.