Improve error handling of broadcast client/server

parent 17ca7ae3
......@@ -17,3 +17,4 @@ Makefile
CMakeFiles
lib
.vs
build
......@@ -17,7 +17,6 @@ BroadcastClient::~BroadcastClient()
if (enet_socket_shutdown(discoverSocket, ENET_SOCKET_SHUTDOWN_READ_WRITE) != 0)
{
cerr << "eNet: Failed to shutdown discover socket" << endl;
return;
}
enet_socket_destroy(discoverSocket);
......@@ -25,7 +24,6 @@ BroadcastClient::~BroadcastClient()
if (enet_socket_shutdown(dataSocket, ENET_SOCKET_SHUTDOWN_READ_WRITE) != 0)
{
cerr << "eNet: Failed to shutdown data socket" << endl;
return;
}
enet_socket_destroy(dataSocket);
......@@ -129,6 +127,9 @@ void BroadcastClient::sendPacket(enet_uint32 host, enet_uint16 port, PacketType
broadcast_packet *BroadcastClient::recieveData(ENetSocket socket, ENetAddress *address)
{
if(socket == ENET_SOCKET_NULL)
return nullptr;
ENetSocketSet set;
ENET_SOCKETSET_EMPTY(set);
ENET_SOCKETSET_ADD(set, socket);
......
......@@ -19,7 +19,6 @@ BroadcastServer::~BroadcastServer()
if (enet_socket_shutdown(discoverSocket, ENET_SOCKET_SHUTDOWN_READ_WRITE) != 0)
{
cerr << "eNet: Failed to shutdown discover socket" << endl;
return;
}
enet_socket_destroy(discoverSocket);
......@@ -27,7 +26,6 @@ BroadcastServer::~BroadcastServer()
if (enet_socket_shutdown(dataSocket, ENET_SOCKET_SHUTDOWN_READ_WRITE) != 0)
{
cerr << "eNet: Failed to shutdown data socket" << endl;
return;
}
enet_socket_destroy(dataSocket);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment