Error Checking and Handling
#include "stdafx.h"
#include <WinSock2.h>
int _tmain(int argc, _TCHAR* argv[])
{
WSADATA wsaData;
int Ret;
//加载winsock库 第二个参数 用与其加载库版本有关信息填充这个结构。版本2.2
if ((Ret = WSAStartup(MAKEWORD(2,2),&wsaData))!= 0)
{
printf("wsastartup failed with error %d \n",Ret);
return 0;
}
if(WSACleanup() == SOCKET_ERROR)
{
printf("wsacleanup failed with error %d \n",WSAGetLastError());
}
return 0;
}

浙公网安备 33010602011771号