CString IOCPS::ErrorCode2Text(DWORD dw)
{
CString error="";
// Put your own common error text here (give more explaination etc..)
switch(dw)
{
case WSAEFAULT:
error="WSAEFAULT The buf parameter is not completely contained in a valid part of the user address space.";
break;
case WSAENOTCONN:
error="WSAENOTCONN The socket is not connected.";
break;
case WSAEINTR:
error="WSAEINTR The (blocking) call was canceled through WSACancelBlockingCall. ";
break;
case WSAENOTSOCK:
error=" WSAENOTSOCK The descriptor s is not a socket.";
break;
case WSANOTINITIALISED:
error="WSANOTINITIALISED: A successful WSAStartup call must occur before using this function.";
break;
case WSAENETDOWN:
error="WSAENETDOWN The network subsystem has failed.";
break;
case WSAEINPROGRESS:
error="WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.";
break;
case WSAENETRESET:
error=" WSAENETRESET The connection has been broken due to the keep-alive activity detecting a failure while the operation was in progress.";
break;
case WSAEOPNOTSUPP:
error="WSAEOPNOTSUPP MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, OOB data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only send operations. ";
break;
case WSAESHUTDOWN:
error="WSAESHUTDOWN The socket has been shut down; it is not possible to receive on a socket after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH.";
break;
case WSAEWOULDBLOCK:
error=" WSAEWOULDBLOCK The socket is marked as nonblocking and the receive operation would block. ";
break;
case WSAEMSGSIZE:
error=" WSAENOTSOCK The message was too large to fit into the specified buffer and was truncated.";
break;
case WSAEINVAL:
error="WSAEINVAL The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled or (for byte stream sockets only) len was zero or negative. ";
case WSAECONNABORTED:
error=" WSAECONNABORTED The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.";
break;
case WSAETIMEDOUT:
error="WSAETIMEDOUT The connection has been dropped because of a network failure or because the peer system failed to respond. ";
break;
case WSAECONNRESET:
//error="WSAECONNRESET The virtual circuit was reset by the remote side executing a hard or abortive close.";
error="WSAECONNRESET Connection dropped..";
break;
default:
error="";
break;
}
// Use system format..
if(error.IsEmpty())
{
LPVOID lpMsgBuf;
error="";
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
error.Format("%s",lpMsgBuf);
LocalFree(lpMsgBuf);
}
return error;
}