我正在尝试移植 TCP 应用程序(特别是tcpsockets),但是我收到此错误:
错误:“fcntl”未在此范围内声明
我已经写了这些包括
#ifdef WIN32
#define _WIN32_WINNT 0x0600 //enable
#include <Ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
typedef int socklen_t;
void close(int socket){closesocket(socket);}
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
Run Code Online (Sandbox Code Playgroud)
这解决了大部分参考文献,但fcntl
没有找到。我怎样才能找到它的正确参考?或者也许有另一种 Windows 方法可以替代它?
fcntl()
Windows 上不存在。对于套接字,等效函数是ioctlsocket()
。fcntl()
但是,Linux 中套接字上的文件控制与 Windows 中的文件控制非常不同,因此并非您使用的所有命令都可以移植到 Windows,或者它们可能需要不同的 API。
归档时间: |
|
查看次数: |
7417 次 |
最近记录: |