2013-11-25 20:27:23 +01:00
|
|
|
#include "WinsockFunctions.h"
|
|
|
|
#include <WinSock2.h>
|
|
|
|
|
2013-11-26 13:45:03 +01:00
|
|
|
bool InitWinSock()
|
2013-11-25 20:27:23 +01:00
|
|
|
{
|
|
|
|
WSADATA wsaData;
|
|
|
|
return WSAStartup(MAKEWORD(2, 2), &wsaData) == NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2013-11-26 13:45:03 +01:00
|
|
|
void ShutdownWinSock()
|
2013-11-25 20:27:23 +01:00
|
|
|
{
|
|
|
|
WSACleanup();
|
2013-11-26 13:45:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::wstring GetErrorMessage(int errorCode)
|
|
|
|
{
|
|
|
|
LPWSTR lpMessage;
|
|
|
|
std::wstring retVal(L"Succesful");
|
|
|
|
|
|
|
|
DWORD bufLen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS ,
|
|
|
|
NULL,
|
|
|
|
errorCode ,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) ,
|
|
|
|
(LPWSTR)&lpMessage,
|
|
|
|
0 ,
|
|
|
|
NULL );
|
|
|
|
|
|
|
|
if(bufLen)
|
|
|
|
{
|
|
|
|
retVal = lpMessage;
|
|
|
|
|
|
|
|
LocalFree(lpMessage);
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2013-11-27 11:28:11 +01:00
|
|
|
//Added this if bufLen is 0
|
|
|
|
return retVal;
|
2013-11-25 20:27:23 +01:00
|
|
|
}
|