更改为win下跨平台的程序

#include <winsock2.h>

#ifdef _WIN32
WORD wVersionRequested;
WSADATA wsaData;
int err;
int connectCount = 0;
struct sockaddr_in RecvIndexAddr;
int nNetTimeout= 3000;

wVersionRequested = MAKEWORD(2,2);

err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we couldn‘t find a usable */
/* WinSock DLL. */
return FALSE;
}

/* Confirm that the WinSock DLL supports 2.0.*/
/* Note that if the DLL supports versions greater */
/* than 2.0 in addition to 2.0, it will still return */
/* 2.0 in wVersion since that is the version we */

/* requested. */

if ( LOBYTE( wsaData.wVersion ) != 2 ||
HIBYTE( wsaData.wVersion ) != 2 ) {
/* Tell the user that we couldn‘t find a usable */
/* WinSock DLL. */
WSACleanup();
return FALSE;
}
#endif


CmakeLists.txt 添加 link_libraries(-lws2_32)



更改为win下跨平台的程序

上一篇:windows+mingw编译CTK框架


下一篇:Activiti 流程启动及节点流转源码分析