mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Use WSA error codes for startup/shutdown
This commit is contained in:
parent
6e3fb73a82
commit
04be5e0e64
@ -42,6 +42,7 @@
|
|||||||
#include "engine/baseclient.h"
|
#include "engine/baseclient.h"
|
||||||
#include "engine/host_cmd.h"
|
#include "engine/host_cmd.h"
|
||||||
#include "engine/host_state.h"
|
#include "engine/host_state.h"
|
||||||
|
#include "engine/net.h"
|
||||||
#include "engine/net_chan.h"
|
#include "engine/net_chan.h"
|
||||||
#include "engine/sv_main.h"
|
#include "engine/sv_main.h"
|
||||||
#include "engine/sys_dll.h"
|
#include "engine/sys_dll.h"
|
||||||
@ -73,7 +74,7 @@ void Systems_Init()
|
|||||||
int nError = ::WSAStartup(MAKEWORD(2, 2), &wsaData);
|
int nError = ::WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||||
if (nError != 0)
|
if (nError != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to start Winsock via WSAStartup. Error: " << nError << std::endl;
|
std::cerr << "Failed to start Winsock via WSAStartup: (" << NET_ErrorString(WSAGetLastError()) << ")." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin the detour transaction to hook the the process
|
// Begin the detour transaction to hook the the process
|
||||||
@ -149,7 +150,7 @@ void Systems_Shutdown()
|
|||||||
int nError = ::WSACleanup();
|
int nError = ::WSACleanup();
|
||||||
if (nError != 0)
|
if (nError != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to stop winsock via WSACleanup. Error: " << nError << std::endl;
|
std::cerr << "Failed to stop winsock via WSACleanup: (" << NET_ErrorString(WSAGetLastError()) << ")." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin the detour transaction to unhook the the process
|
// Begin the detour transaction to unhook the the process
|
||||||
|
@ -51,6 +51,7 @@ const char* NET_ErrorString(int iCode)
|
|||||||
case WSAELOOP : return "WSAELOOP";
|
case WSAELOOP : return "WSAELOOP";
|
||||||
case WSAENAMETOOLONG : return "WSAENAMETOOLONG";
|
case WSAENAMETOOLONG : return "WSAENAMETOOLONG";
|
||||||
case WSAEHOSTDOWN : return "WSAEHOSTDOWN";
|
case WSAEHOSTDOWN : return "WSAEHOSTDOWN";
|
||||||
|
case WSAEPROCLIM : return "WSAEPROCLIM";
|
||||||
case WSASYSNOTREADY : return "WSASYSNOTREADY";
|
case WSASYSNOTREADY : return "WSASYSNOTREADY";
|
||||||
case WSAVERNOTSUPPORTED: return "WSAVERNOTSUPPORTED";
|
case WSAVERNOTSUPPORTED: return "WSAVERNOTSUPPORTED";
|
||||||
case WSANOTINITIALISED : return "WSANOTINITIALISED";
|
case WSANOTINITIALISED : return "WSANOTINITIALISED";
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "tier2/socketcreator.h"
|
#include "tier2/socketcreator.h"
|
||||||
#include "protoc/sv_rcon.pb.h"
|
#include "protoc/sv_rcon.pb.h"
|
||||||
#include "protoc/cl_rcon.pb.h"
|
#include "protoc/cl_rcon.pb.h"
|
||||||
|
#include "engine/net.h"
|
||||||
#include "netconsole/netconsole.h"
|
#include "netconsole/netconsole.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -23,7 +24,7 @@ bool CNetCon::Init(void)
|
|||||||
|
|
||||||
if (nError != 0)
|
if (nError != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to start Winsock via WSAStartup. Error: " << nError << std::endl;
|
std::cerr << "Failed to start Winsock via WSAStartup: (" << NET_ErrorString(WSAGetLastError()) << ")." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ bool CNetCon::Shutdown(void)
|
|||||||
int nError = ::WSACleanup();
|
int nError = ::WSACleanup();
|
||||||
if (nError != 0)
|
if (nError != 0)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to stop winsock via WSACleanup. Error: " << nError << std::endl;
|
std::cerr << "Failed to stop winsock via WSACleanup: (" << NET_ErrorString(WSAGetLastError()) << ")." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -212,7 +213,7 @@ bool CNetCon::Connect(const std::string& svInAdr, const std::string& svInPort)
|
|||||||
|
|
||||||
if (m_pSocket->ConnectSocket(*m_pNetAdr2, true) == SOCKET_ERROR)
|
if (m_pSocket->ConnectSocket(*m_pNetAdr2, true) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to connect. Error: 'SOCKET_ERROR'. Verify IP and PORT." << std::endl;
|
std::cerr << "Failed to connect. Error: (SOCKET_ERROR). Verify IP and PORT." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::cout << "Connected to: " << m_pNetAdr2->GetIPAndPort() << std::endl;
|
std::cout << "Connected to: " << m_pNetAdr2->GetIPAndPort() << std::endl;
|
||||||
@ -240,7 +241,7 @@ void CNetCon::Send(const std::string& svMessage) const
|
|||||||
int nSendResult = ::send(m_pSocket->GetAcceptedSocketData(0)->m_hSocket, svMessage.c_str(), svMessage.size(), MSG_NOSIGNAL);
|
int nSendResult = ::send(m_pSocket->GetAcceptedSocketData(0)->m_hSocket, svMessage.c_str(), svMessage.size(), MSG_NOSIGNAL);
|
||||||
if (nSendResult == SOCKET_ERROR)
|
if (nSendResult == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
std::cout << "Failed to send message: SOCKET_ERROR." << std::endl;
|
std::cout << "Failed to send message: (SOCKET_ERROR)." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user