sfTcpListener_accept now returns a null pointer when it fails

This commit is contained in:
Laurent Gomila committed 2013-07-09 15:46:17 +02:00
1 parent 12b7c5a6a5
commit 91e11cc095
2 files changed
+13 -1

No files matched your search

+4
View File
@@ -112,6 +112,10 @@ CSFML_NETWORK_API sfSocketStatus sfTcpListener_listen(sfTcpListener* listener, u
/// If the socket is in blocking mode, this function will
/// not return until a connection is actually received.
///
/// The \a connected argument points to a valid sfTcpSocket pointer
/// in case of success (the function returns sfSocketDone), it points
/// to a NULL pointer otherwise.
///
/// \param listener TCP listener object
/// \param connected Socket that will hold the new connection
///
+9 -1
View File
@@ -82,5 +82,13 @@ sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** conne
CSFML_CHECK_RETURN(connected, sfSocketError);
*connected = new sfTcpSocket;
return static_cast<sfSocketStatus>(listener->This.accept((*connected)->This));
sfSocketStatus status = static_cast<sfSocketStatus>(listener->This.accept((*connected)->This));
if (status != sfSocketDone)
{
delete *connected;
*connected = NULL;
}
return status;
}