简体   繁体   English

无法在VS2008中打开套接字程序标头

[英]Unable to open the socket program header in VS2008

idevs.h, netinet/in_systm.h, netinet/ip.h, netinet/tcp.h openssl/ssl.h sys/socket.h idevs.h,netinet / in_systm.h,netinet / ip.h,netinet / tcp.h openssl / ssl.h sys / socket.h

These header files can work in Linux but in visual studio 2008 compile error says unable to open header file. 这些头文件可以在Linux中工作,但是在Visual Studio 2008中,编译错误表示无法打开头文件。 These are socket program related headers. 这些是与套接字程序相关的头。 (I am unable to get any proper result from web search) (我无法从网络搜索中获得任何正确的结果)

Problem: 问题:

Please let me know any dll I have include for these headers or any other equivalent headers are available ? 请让我知道我为这些标头包含的任何dll或任何其他等效标头可用吗?

Thanks in advance. 提前致谢。

In windows environment you need to include the windows specific headers like winsock.h and others ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms738545(v=vs.85).aspx ). 在Windows环境中,您需要包含Windows特定的标头,例如winsock.h和其他标头( http://msdn.microsoft.com/zh-cn/library/windows/desktop/ms738545(v=vs.85).aspx )。 You need to switch between headers using the #ifdef statements when doing builds for different platforms. 在针对不同平台进行构建时,需要使用#ifdef语句在标头之间切换。

Nobody ever promised that windows implementation of the sockets concept is 100% identical to the one of Unix. 没有人承诺过Windows套接字概念的实现与Unix的实现100%相同。 These implementations have a lot in common, but differences are also present. 这些实现有很多共同点,但也存在差异。

Sockets are not part of the C++ standard and are implemented in different ways in Linux and Windows. 套接字不是C ++标准的一部分,并且在Linux和Windows中以不同的方式实现。 That means, that the native socket libraries are different in both OSes, and Windows has other headers for its socket API than Linux. 这意味着,本机套接字库在两个操作系统中都是不同的,并且Windows具有其套接字API的其他标头,而不是Linux。 So you will not only have to include other headers but might also need to use other functions. 因此,您不仅必须包含其他标头,而且可能还需要使用其他功能。

Depending on what you want to achieve, you might want to use a library that wraps the OS specific parts and provides a portable interface. 根据要实现的目标,您可能需要使用包装OS特定部分并提供可移植界面的库。 There are several more or less portable networking libraries, one of the best known might be Boost.Asio 有或多或少的便携式网络库,其中最著名的可能是Boost.Asio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM