@@ -99,6 +99,10 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
9999/// If the socket was previously listening to another port,
100100/// it will be stopped first and bound to the new port.
101101///
102+ /// When providing `sfTcpListener_anyPort()` as port, the listener
103+ /// will request an available port from the system.
104+ /// The chosen port can be retrieved by calling `sfTcpListener_getLocalPort()`.
105+ ///
102106/// If there is no specific address to listen to, pass sfIpAddress_Any
103107///
104108/// \param listener TCP listener object
@@ -110,6 +114,17 @@ CSFML_NETWORK_API unsigned short sfTcpListener_getLocalPort(const sfTcpListener*
110114////////////////////////////////////////////////////////////
111115CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen (sfTcpListener * listener , unsigned short port , sfIpAddress address );
112116
117+ ////////////////////////////////////////////////////////////
118+ /// \brief Stop listening and close the socket
119+ ///
120+ /// This function gracefully stops the listener. If the
121+ /// socket is not listening, this function has no effect.
122+ ///
123+ /// \param listener TCP listener object
124+ ///
125+ ////////////////////////////////////////////////////////////
126+ CSFML_NETWORK_API void sfTcpListener_close (sfTcpListener * listener );
127+
113128////////////////////////////////////////////////////////////
114129/// \brief Accept a new connection
115130///
@@ -127,3 +142,12 @@ CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, u
127142///
128143////////////////////////////////////////////////////////////
129144CSFML_NETWORK_API sfSocketStatus sfTcpListener_accept (sfTcpListener * listener , sfTcpSocket * * connected );
145+
146+ ////////////////////////////////////////////////////////////
147+ /// \brief Return the special value that tells the system
148+ /// to pick any available port
149+ ///
150+ /// \return The value to use for any port
151+ ///
152+ ////////////////////////////////////////////////////////////
153+ CSFML_NETWORK_API unsigned short sfTcpListener_anyPort (void );
0 commit comments