diff --git a/build/vc2008/SFML.sln b/build/vc2008/SFML.sln index 5fdfc96c2..a1a90c42f 100644 --- a/build/vc2008/SFML.sln +++ b/build/vc2008/SFML.sln @@ -60,7 +60,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sound", "..\..\examples\bui {C061A27D-7CA0-4179-9869-672FA04A86A8} = {C061A27D-7CA0-4179-9869-672FA04A86A8} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sound-capture", "..\..\examples\build\vc2008\sound-capture.vcproj", "{34EBDA13-AFA3-4AD9-AB64-2B2D40E09573}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sound_capture", "..\..\examples\build\vc2008\sound-capture.vcproj", "{34EBDA13-AFA3-4AD9-AB64-2B2D40E09573}" ProjectSection(ProjectDependencies) = postProject {B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2} = {B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2} {C061A27D-7CA0-4179-9869-672FA04A86A8} = {C061A27D-7CA0-4179-9869-672FA04A86A8} diff --git a/include/SFML/Network/TcpListener.hpp b/include/SFML/Network/TcpListener.hpp index 93694504d..e958e1e77 100644 --- a/include/SFML/Network/TcpListener.hpp +++ b/include/SFML/Network/TcpListener.hpp @@ -79,6 +79,17 @@ public : //////////////////////////////////////////////////////////// Status Listen(unsigned short port); + //////////////////////////////////////////////////////////// + /// \brief Stop listening and close the socket + /// + /// This function gracefully stops the listener. If the + /// socket is not listening, this function has no effect. + /// + /// \see Listen + /// + //////////////////////////////////////////////////////////// + void Close(); + //////////////////////////////////////////////////////////// /// \brief Accept a new connection /// @@ -110,16 +121,21 @@ public : /// a given port and waits for connections on that port. /// This is all it can do. /// -/// When a new connection is received, the socket returns a -/// new instance of sf::TcpSocket that is properly -/// initialized and can be used to communicate with the -/// new client. +/// 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. +/// /// Usage example: /// \code /// // Create a listener socket and make it wait for new diff --git a/src/SFML/Network/TcpListener.cpp b/src/SFML/Network/TcpListener.cpp index 89fd19ca3..5cd8e889e 100644 --- a/src/SFML/Network/TcpListener.cpp +++ b/src/SFML/Network/TcpListener.cpp @@ -87,6 +87,14 @@ Socket::Status TcpListener::Listen(unsigned short port) } +//////////////////////////////////////////////////////////// +void TcpListener::Close() +{ + // Simply close the socket + Socket::Close(); +} + + //////////////////////////////////////////////////////////// Socket::Status TcpListener::Accept(TcpSocket& socket) {