TCP/IP 套接字 API 书
我最近购买了这本书来了解有关构建网络套接字的一些基础知识在窗户下。例如,我在编译本书中编写的代码时遇到问题 - 在第一个程序中,它告诉您包含
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
我在 Visual C++ 中尝试过这些,但编译器返回错误;包含未找到的文件。有人读过这本书或了解这本书吗?
I have recently bought this book to get to know some basics about building networking sockets under windows. I'm having problems with compiling the code written in this book for example - in first program it tells you to include
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
I tried these in visual c++ but the compiler return errors; include files not found. has anyone read from the book or know something about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Windows 中,您需要包含
WinSock2.h
才能访问 Windows Sockets API。您问题中的信息看起来像是针对 Unix 系统套接字访问的。Windows Sockets API (WinSock v2.0) 文档为 在这里。来自 Unix 套接字的实际函数调用大多数也可以在 Windows 上使用,但还有一堆名为
WSA*
的 Windows 特定函数,它们对于编写高效的 Windows 特定套接字代码非常有帮助。In Windows you need to include
WinSock2.h
to get access to the Windows Sockets API. The info in your question looks like it's targeted at Unix system sockets access.Windows Sockets API (WinSock v2.0) docs are here. The actual function calls from Unix sockets are mostly also available on Windows but there are also a bunch of Windows-specific functions named
WSA*
that are very helpful in writing efficient Windows-specific sockets code.