首页 > Windows开发 > 详细

更改为win下跨平台的程序

时间:2020-06-29 12:42:02      阅读:66      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!