码迷,mamicode.com
首页 > Windows程序 > 详细

更改为win下跨平台的程序

时间:2020-06-29 13:13:55      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:rar   cmake   false   ||   user   平台   addition   sas   ted   

#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下跨平台的程序

标签:rar   cmake   false   ||   user   平台   addition   sas   ted   

原文地址:https://www.cnblogs.com/xpylovely/p/13207345.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!