class final
#include <core/net/tcp_listener.hpp>
TcpListener 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
andport
. - 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:: valid() const
Check if connection is valid.
Returns | Whether inner sock is connected. |
---|
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. |