Added the TcpListener::Close function

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1585 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-10-26 19:38:26 +00:00
parent 16d986c762
commit 61dc7e0100
3 changed files with 30 additions and 6 deletions

View File

@ -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}

View File

@ -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

View File

@ -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)
{