TcpListener

Socket that listens to new TCP connections.

A listener socket is a special type of socket that listens to a given port and waits for connections on that port.

This is all it can do.

When a new connection is received, you must call accept and the listener returns a new instance of sf::TcpSocket that is properly initialized and can be used to communicate with the new client.

Listener sockets are specific to the TCP protocol, UDP sockets are connectionless and can therefore communicate directly. As a consequence, a listener socket will always return the new connections as sf::TcpSocket instances.

A listener is automatically closed on destruction, like all other types of socket. However if you want to stop listening before the socket is destroyed, you can call its close() function.

Constructors

this
this()

Default constructor

Destructor

~this
~this()

Destructor

Members

Functions

accept
Status accept(TcpSocket socket)

Accept a new connection. If the socket is in blocking mode, this function will not return until a connection is actually received.

getLocalPort
ushort getLocalPort()

Get the port to which the socket is bound locally.

isBlocking
bool isBlocking()

Set the blocking state of the socket.

listen
Status listen(ushort port)

Start listening for connections.

setBlocking
void setBlocking(bool blocking)

Tell whether the socket is in blocking or non-blocking mode.

Variables

sfPtr
sfTcpListener* sfPtr;
Undocumented in source.

Inherited Members

From Socket

Status
enum Status

Status codes that may be returned by socket functions.

AnyPort
enum AnyPort;

Special value that tells the system to pick any available port.

Meta