Class TCPListener#
Defined in File TCPListener.h
Inheritance Relationships#
Base Type#
public TRAP::Network::Socket
(Class Socket)
Class Documentation#
-
class TCPListener : public TRAP::Network::Socket#
Socket that listens to new TCP connections.
Public Functions
-
constexpr TCPListener() noexcept#
Constructor.
-
consteval TCPListener(const TCPListener&) = delete#
Copy constructor.
-
consteval TCPListener &operator=(const TCPListener&) = delete#
Copy assignment operator.
-
constexpr TCPListener(TCPListener&&) noexcept = default#
Move constructor.
-
TCPListener &operator=(TCPListener&&) noexcept = default#
Move assignment operator.
-
~TCPListener() override = default#
Destructor.
-
u16 GetLocalPort() const#
Get the port to which the socket is bound locally.
If the socket is not listening to a port, this function returns 0.
- Returns:
Port to which the socket is bound.
-
Status Listen(u16 port, const IPv4Address &address = IPv4Address::Any)#
Start listening for incoming connection attempts.
This function makes the socket start listening on the specified port, waiting for incoming connection attempts.
If the socket is already listening on a port when this function is called, it will stop listening on the old port before starting to listen on the new port.
When providing TRAP::Network::Socket::AnyPort as port, the listener will request an available port from the system. The chosen port can be retrieved by calling GetLocalPort().
- Parameters:
port – Port to listen on for incoming connection attempts.
address – Address of the interface to listen on.
- Returns:
Status code.
-
void Close()#
Stop listening and close the socket.
This function gracefully stops the listener. If the socket is not listening, this function has no effect.
-
constexpr TCPListener() noexcept#