#ifndef _TRI_WSA_ERROR_
#define  _TRI_WSA_ERROR_
#include <Winsock2.h>

char * getWSAErrorString()
{
	int nErr = WSAGetLastError();
	char * pszErr = "WSAUNKNOWN";
	if (nErr == WSANOTINITIALISED)
		pszErr = "WSANOTINITIALISED";
	else if (nErr == WSAEINTR)
		pszErr = "WSAEINTR";
	else if (nErr == WSAEBADF)
		pszErr = "WSAEBADF";
	else if (nErr == WSAEACCES)
		pszErr = "WSAEACCES";
	else if (nErr == WSAEFAULT)
		pszErr = "WSAEFAULT";
	else if (nErr == WSAEINVAL)
		pszErr = "WSAEINVAL";
	else if (nErr == WSAEMFILE)
		pszErr = "WSAEMFILE";
	else if (nErr == WSAEWOULDBLOCK)
		pszErr = "WSAEWOULDBLOCK";
	else if (nErr == WSAEINPROGRESS)
		pszErr = "WSAEINPROGRESS";
	else if (nErr == WSAEALREADY)
		pszErr = "WSAEALREADY";
	else if (nErr == WSAENOTSOCK)
		pszErr = "WSAENOTSOCK";
	else if (nErr == WSAEDESTADDRREQ)
		pszErr = "WSAEDESTADDRREQ";
	else if (nErr == WSAEMSGSIZE)
		pszErr = "WSAEMSGSIZE";
	else if (nErr == WSAEPROTOTYPE)
		pszErr = "WSAEPROTOTYPE";
	else if (nErr == WSAENOPROTOOPT)
		pszErr = "WSAENOPROTOOPT";
	else if (nErr == WSAEPROTONOSUPPORT)
		pszErr = "WSAEPROTONOSUPPORT";
	else if (nErr == WSAESOCKTNOSUPPORT)
		pszErr = "WSAESOCKTNOSUPPORT";
	else if (nErr == WSAEOPNOTSUPP)
		pszErr = "WSAEOPNOTSUPP";
	else if (nErr == WSAEPFNOSUPPORT)
		pszErr = "WSAEPFNOSUPPORT";
	else if (nErr == WSAEAFNOSUPPORT)
		pszErr = "WSAEAFNOSUPPORT";
	else if (nErr == WSAEADDRINUSE)
		pszErr = "WSAEADDRINUSE";
	else if (nErr == WSAEADDRNOTAVAIL)
		pszErr = "WSAEADDRNOTAVAIL";
	else if (nErr == WSAENETDOWN)
		pszErr = "WSAENETDOWN";
	else if (nErr == WSAENETUNREACH)
		pszErr = "WSAENETUNREACH";
	else if (nErr == WSAENETRESET)
		pszErr = "WSAENETRESET";
	else if (nErr == WSAECONNABORTED)
		pszErr = "WSAECONNABORTED";
	else if (nErr == WSAECONNRESET)
		pszErr = "WSAECONNRESET";
	else if (nErr == WSAENOBUFS)
		pszErr = "WSAENOBUFS";
	else if (nErr == WSAEISCONN)
		pszErr = "WSAEISCONN";
	else if (nErr == WSAENOTCONN)
		pszErr = "WSAENOTCONN";
	else if (nErr == WSAESHUTDOWN)
		pszErr = "WSAESHUTDOWN";
	else if (nErr == WSAETOOMANYREFS)
		pszErr = "WSAETOOMANYREFS";
	else if (nErr == WSAETIMEDOUT)
		pszErr = "WSAETIMEDOUT";
	else if (nErr == WSAECONNREFUSED)
		pszErr = "WSAECONNREFUSED";
	else if (nErr == WSAELOOP)
		pszErr = "WSAELOOP";
	else if (nErr == WSAENAMETOOLONG)
		pszErr = "WSAENAMETOOLONG";
	else if (nErr == WSAEHOSTDOWN)
		pszErr = "WSAEHOSTDOWN";
	else if (nErr == WSAEHOSTUNREACH)
		pszErr = "WSAEHOSTUNREACH";
	else if (nErr == WSAENOTEMPTY)
		pszErr = "WSAENOTEMPTY";
	else if (nErr == WSAEPROCLIM)
		pszErr = "WSAEPROCLIM";
	else if (nErr == WSAEUSERS)
		pszErr = "WSAEUSERS";
	else if (nErr == WSAEDQUOT)
		pszErr = "WSAEDQUOT";
	else if (nErr == WSAESTALE)
		pszErr = "WSAESTALE";
	else if (nErr == WSAEREMOTE)
		pszErr = "WSAEREMOTE";
	else if (nErr == WSASYSNOTREADY)
		pszErr = "WSASYSNOTREADY";
	else if (nErr == WSAVERNOTSUPPORTED)
		pszErr = "WSAVERNOTSUPPORTED";
	else if (nErr == WSANOTINITIALISED)
		pszErr = "WSANOTINITIALISED";
	else if (nErr == WSAEDISCON)
		pszErr = "WSAEDISCON";
	else if (nErr == WSAENOMORE)
		pszErr = "WSAENOMORE";
	else if (nErr == WSAECANCELLED)
		pszErr = "WSAECANCELLED";
	else if (nErr == WSAEINVALIDPROCTABLE)
		pszErr = "WSAEINVALIDPROCTABLE";
	else if (nErr == WSAEINVALIDPROVIDER)
		pszErr = "WSAEINVALIDPROVIDER";
	else if (nErr == WSAEPROVIDERFAILEDINIT)
		pszErr = "WSAEPROVIDERFAILEDINIT";
	else if (nErr == WSASYSCALLFAILURE)
		pszErr = "WSASYSCALLFAILURE";
	else if (nErr == WSASERVICE_NOT_FOUND)
		pszErr = "WSASERVICE_NOT_FOUND";
	else if (nErr == WSATYPE_NOT_FOUND)
		pszErr = "WSATYPE_NOT_FOUND";
	else if (nErr == WSA_E_NO_MORE)
		pszErr = "WSA_E_NO_MORE";
	else if (nErr == WSA_E_CANCELLED)
		pszErr = "WSA_E_CANCELLED";
	else if (nErr == WSAEREFUSED)
		pszErr = "WSAEREFUSED";
	else if (nErr == WSAHOST_NOT_FOUND)
		pszErr = "WSAHOST_NOT_FOUND";
	else if (nErr == WSATRY_AGAIN)
		pszErr = "WSATRY_AGAIN";
	else if (nErr == WSANO_RECOVERY)
		pszErr = "WSANO_RECOVERY";
	else if (nErr == WSANO_DATA)
		pszErr = "WSANO_DATA";
	else if (nErr == WSA_QOS_RECEIVERS)
		pszErr = "WSA_QOS_RECEIVERS";
	else if (nErr == WSA_QOS_SENDERS)
		pszErr = "WSA_QOS_SENDERS";
	else if (nErr == WSA_QOS_NO_SENDERS)
		pszErr = "WSA_QOS_NO_SENDERS";
	else if (nErr == WSA_QOS_NO_RECEIVERS)
		pszErr = "WSA_QOS_NO_RECEIVERS";
	else if (nErr == WSA_QOS_REQUEST_CONFIRMED)
		pszErr = "WSA_QOS_REQUEST_CONFIRMED";
	else if (nErr == WSA_QOS_ADMISSION_FAILURE)
		pszErr = "WSA_QOS_ADMISSION_FAILURE";
	else if (nErr == WSA_QOS_POLICY_FAILURE)
		pszErr = "WSA_QOS_POLICY_FAILURE";
	else if (nErr == WSA_QOS_BAD_STYLE)
		pszErr = "WSA_QOS_BAD_STYLE";
	else if (nErr == WSA_QOS_BAD_OBJECT)
		pszErr = "WSA_QOS_BAD_OBJECT";
	else if (nErr == WSA_QOS_TRAFFIC_CTRL_ERROR)
		pszErr = "WSA_QOS_TRAFFIC_CTRL_ERROR";
	else if (nErr == WSA_QOS_GENERIC_ERROR)
		pszErr = "WSA_QOS_GENERIC_ERROR";
	else if (nErr == WSA_QOS_ESERVICETYPE)
		pszErr = "WSA_QOS_ESERVICETYPE";
	else if (nErr == WSA_QOS_EFLOWSPEC)
		pszErr = "WSA_QOS_EFLOWSPEC";
	else if (nErr == WSA_QOS_EPROVSPECBUF)
		pszErr = "WSA_QOS_EPROVSPECBUF";
	else if (nErr == WSA_QOS_EFILTERSTYLE)
		pszErr = "WSA_QOS_EFILTERSTYLE";
	else if (nErr == WSA_QOS_EFILTERTYPE)
		pszErr = "WSA_QOS_EFILTERTYPE";
	else if (nErr == WSA_QOS_EFILTERCOUNT)
		pszErr = "WSA_QOS_EFILTERCOUNT";
	else if (nErr == WSA_QOS_EOBJLENGTH)
		pszErr = "WSA_QOS_EOBJLENGTH";
	else if (nErr == WSA_QOS_EFLOWCOUNT)
		pszErr = "WSA_QOS_EFLOWCOUNT";
#ifdef _MSC_VER
	else if (nErr == WSA_QOS_EUNKOWNPSOBJ)
		pszErr = "WSA_QOS_EUNKOWNPSOBJ";
#endif
	else if (nErr == WSA_QOS_EPOLICYOBJ)
		pszErr = "WSA_QOS_EPOLICYOBJ";
	else if (nErr == WSA_QOS_EFLOWDESC)
		pszErr = "WSA_QOS_EFLOWDESC";
	else if (nErr == WSA_QOS_EPSFLOWSPEC)
		pszErr = "WSA_QOS_EPSFLOWSPEC";
	else if (nErr == WSA_QOS_EPSFILTERSPEC)
		pszErr = "WSA_QOS_EPSFILTERSPEC";
	else if (nErr == WSA_QOS_ESDMODEOBJ)
		pszErr = "WSA_QOS_ESDMODEOBJ";
	else if (nErr == WSA_QOS_ESHAPERATEOBJ)
		pszErr = "WSA_QOS_ESHAPERATEOBJ";
	else if (nErr == WSA_QOS_RESERVED_PETYPE)
		pszErr = "WSA_QOS_RESERVED_PETYPE";
	return pszErr;
}
#endif
