TCP/IP套接字API书

J.N*_*J.N 1 c sockets windows tcp visual-c++-2005

我最近买了这本书,以了解有关在Windows下构建网络套接字的一些基础知识.我在编写本书中编写的代码时遇到了问题 - 在第一个程序中它告诉你要包括

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Run Code Online (Sandbox Code Playgroud)

我在visual c ++中尝试了这些,但编译器返回错误; 包含未找到的文件.有没有人从这本书中读过或知道它的一些事情?

Ste*_*end 5

在Windows中,您需要包含WinSock2.h才能访问Windows套接字API.您的问题中的信息看起来像是针对Unix系统套接字访问.

Windows套接字API(WinSock v2.0)文档在这里.从Unix套接字的实际函数调用大多也可在Windows,但也有一堆命名Windows特有的功能WSA*是在编写有效的Windows专用插座的代码非常有帮助.