Some more verbose error reporting

This was SVN commit r1307.
This commit is contained in:
Simon Brenner 2004-11-12 22:11:04 +00:00
parent c6e1e72698
commit 64646cfbbf
4 changed files with 15 additions and 4 deletions

Binary file not shown.

View File

@ -9,6 +9,9 @@
#include "lib.h"
#include "CStr.h"
// ERROR is defined by some windows header. Undef it
#undef ERROR
#include "CLogger.h"
#include <errno.h>
@ -41,6 +44,9 @@ PS_RESULT GetPS_RESULT(int error)
case ECONNREFUSED:
return CONNECT_REFUSED;
default:
char buf[256];
Network_GetErrorString(error, buf, sizeof(buf));
LOG(ERROR, LOG_CAT_NET, "SocketBase.cpp::GetPS_RESULT(): Untranslated error %s[%d]", buf, error);
return PS_FAIL;
}
}
@ -414,7 +420,7 @@ PS_RESULT CSocketBase::Bind(const CSocketAddress &address)
break;
default:
Network_GetErrorString(err, errBuf, sizeof(errBuf));
printf("CServerSocket::Bind(): bind: %s [%d]\n", errBuf, err);
LOG(ERROR, LOG_CAT_NET, "CServerSocket::Bind(): bind: %s [%d] => PS_FAIL", errBuf, err);
}
m_State=SS_UNCONNECTED;
m_Error=ret;
@ -426,7 +432,7 @@ PS_RESULT CSocketBase::Bind(const CSocketAddress &address)
{
int err=Network_LastError;
Network_GetErrorString(err, errBuf, sizeof(errBuf));
printf("CServerSocket::Bind(): listen: %s [%d]\n", errBuf, err);
LOG(ERROR, LOG_CAT_NET, "CServerSocket::Bind(): listen: %s [%d] => PS_FAIL", errBuf, err);
m_State=SS_UNCONNECTED;
return PS_FAIL;
}
@ -445,7 +451,7 @@ PS_RESULT CSocketBase::PreAccept(CSocketAddress &addr)
if (fd != -1)
return PS_OK;
else
return PS_FAIL;
return GetPS_RESULT(Network_LastError);
}
CSocketInternal *CSocketBase::Accept()

View File

@ -342,7 +342,7 @@ public:
* connection by calling Accept or Reject
*
* @param addr A pointer to a SocketAddress
* @return PS_OK or PS_FAIL
* @return PS_OK or an error code
*
* @see Accept(SocketAddress&)
* @see Reject()

View File

@ -3,6 +3,8 @@
#include "Network.h"
#include "StreamSocket.h"
#include <CLogger.h>
CStreamSocket::CStreamSocket()
{}
@ -21,11 +23,14 @@ void *CStreamSocket_ConnectThread(void *data)
CSocketAddress addr;
res=CSocketAddress::Resolve(pSock->m_pConnectHost, pSock->m_ConnectPort, addr);
LOG(NORMAL, LOG_CAT_NET, "CStreamSocket_ConnectThread: Resolve: %s -> %s", res, addr.GetString().c_str());
if (res == PS_OK)
{
pSock->Initialize();
pSock->SetNonBlocking(false);
res=pSock->Connect(addr);
if (res != PS_OK)
LOG(ERROR, LOG_CAT_NET, "CStreamSocket_ConnectThread: Connect: %s", res);
}
if (res == PS_OK)