public string getErrorMessage()
{
// translate "Major:Minor" code into text message.
switch (m_iMajor)
{
case 0:
m_strMsg = "Success";
break;
case 1:
m_strMsg = "Connection setup failure";
switch (m_iMinor)
{
case 1:
m_strMsg += ": connection time out";
break;
case 2:
m_strMsg += ": connection rejected";
break;
case 3:
m_strMsg += ": unable to create/configure UDP socket";
break;
case 4:
m_strMsg += ": abort for security reasons";
break;
default:
break;
}
break;
case 2:
switch (m_iMinor)
{
case 1:
m_strMsg = "Connection was broken";
break;
case 2:
m_strMsg = "Connection does not exist";
break;
default:
break;
}
break;
case 3:
m_strMsg = "System resource failure";
switch (m_iMinor)
{
case 1:
m_strMsg += ": unable to create new threads";
break;
case 2:
m_strMsg += ": unable to allocate buffers";
break;
default:
break;
}
break;
case 4:
m_strMsg = "File system failure";
switch (m_iMinor)
{
case 1:
m_strMsg += ": cannot seek read position";
break;
case 2:
m_strMsg += ": failure in read";
break;
case 3:
m_strMsg += ": cannot seek write position";
break;
case 4:
m_strMsg += ": failure in write";
break;
default:
break;
}
break;
case 5:
m_strMsg = "Operation not supported";
switch (m_iMinor)
{
case 1:
m_strMsg += ": Cannot do this operation on a BOUND socket";
break;
case 2:
m_strMsg += ": Cannot do this operation on a CONNECTED socket";
break;
case 3:
m_strMsg += ": Bad parameters";
break;
case 4:
m_strMsg += ": Invalid socket ID";
break;
case 5:
m_strMsg += ": Cannot do this operation on an UNBOUND socket";
break;
case 6:
m_strMsg += ": Socket is not in listening state";
break;
case 7:
m_strMsg += ": Listen/accept is not supported in rendezous connection setup";
break;
case 8:
m_strMsg += ": Cannot call connect on UNBOUND socket in rendezvous connection setup";
break;
case 9:
m_strMsg += ": This operation is not supported in SOCK_STREAM mode";
break;
case 10:
m_strMsg += ": This operation is not supported in SOCK_DGRAM mode";
break;
case 11:
m_strMsg += ": Another socket is already listening on the same port";
break;
case 12:
m_strMsg += ": Message is too large to send (it must be less than the UDT send buffer size)";
break;
default:
break;
}
break;
case 6:
m_strMsg = "Non-blocking call failure";
switch (m_iMinor)
{
case 1:
m_strMsg += ": no buffer available for sending";
break;
case 2:
m_strMsg += ": no data available for reading";
break;
default:
break;
}
break;
default:
m_strMsg = "Unknown error";
break;
}
// Adding "errno" information
if ((0 != m_iMajor) && (0 < m_iErrno))
{
m_strMsg += ": ";
//LPVOID lpMsgBuf;
//FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, null, m_iErrno, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, null);
//m_strMsg += (char*)lpMsgBuf;
//LocalFree(lpMsgBuf);
}
return m_strMsg;
}