cubos::core::net::TcpListener class final

A TCP socket server, listening for connections.

Constructors, destructors, conversion operators

TcpListener()
Create an empty TCP listener, ready for connecting.
~TcpListener()
Deconstructs by calling close.
TcpListener(const TcpListener&) deleted
Forbid copy construction.

Public functions

auto operator=(const TcpListener&) -> TcpListener& deleted
Forbid assignment.
auto listen(const Address& address, uint16_t port, int maxQueueLength = 4096) -> bool
Start listening for connection at specified address and port.
auto accept(TcpStream& stream) const -> bool
Accepts a new connection.
void close()
Close the listener socket.
auto valid() const -> bool
Check if connection is valid.
auto inner() const -> InnerSocket
Get inner socket handle.
auto setBlocking(bool blocking) -> bool
Control blocking mode of inner socket.

Function documentation

bool cubos::core::net::TcpListener::listen(const Address& address, uint16_t port, int maxQueueLength = 4096)

Start listening for connection at specified address and port.

Parameters
address Destination address.
port Destination port.
maxQueueLength Maximum connection requests.
Returns Whether start listening was successful.

bool cubos::core::net::TcpListener::accept(TcpStream& stream) const

Accepts a new connection.

Parameters
stream out Buffer to store the connection stream.
Returns Whether accepting the connection and creating the stream was successful.

bool cubos::core::net::TcpListener::valid() const

Check if connection is valid.

Returns Whether inner sock is connected.

InnerSocket cubos::core::net::TcpListener::inner() const

Get inner socket handle.

Returns Socket.

bool cubos::core::net::TcpListener::setBlocking(bool blocking)

Control blocking mode of inner socket.

Parameters
blocking Whether to block or not.
Returns Whether setting the block flag was sucessful.