WinSock.h& WinSock2.h使用哪个? [英] WinSock.h & WinSock2.h which to use?

查看:186
本文介绍了WinSock.h& WinSock2.h使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道WinSock.h和WinSock2.h之间的区别。我知道他们不使用相同的库(.lib),但我不知道WinSock2是否只添加了新功能,或者它是否也改进了WinSock 1功能。我正在使用IP / TCP套接字,并希望使用select()管理超时。我还使用多个线程同时管理多个客户端。我应该继续使用WinSock 1.1还是应该转移到WinSock 2?提前致谢。

Does anyone know the differences between WinSock.h and WinSock2.h . I know they don't use the same library (.lib) but I don't know if WinSock2 only adds new features or if it also improves WinSock 1 features. I am working with IP/TCP sockets and want to manage timeouts with select(). I also use multiple threads to manage more than only one client at the same time. Should I continue using WinSock 1.1 or should I move to WinSock 2? Thanks in advance.

推荐答案

您应该使用 winsock2.h

几点:


  • winsock.h 应与 wsock32.lib 一起使用, winsock2.h 应与 ws2_32一起使用.lib

  • winsock.h winsock2.h 不应该在同一个项目中, winsock2.h 替换 winsock.h 而不是扩展它。

  • winsock.h 只应在目标旧版Windows(如Windows 95 / Windows NT 3.5)时使用。

  • winsock.h should be used with wsock32.lib and winsock2.h should be used with ws2_32.lib
  • winsock.h and winsock2.h should not be together in the same project, winsock2.h replaces winsock.h and not extends it.
  • winsock.h should only be used if you target old version of Windows like Windows 95 / Windows NT 3.5.

版本1.1 (<$ c $ Winsock的c> winsock.h )是在Windows for Workgroups(代号为Snowball)的附加软件包(称为Wolverine)中提供的。它是Windows 95和Windows NT从版本3.5及更高版本(Windows NT的初始商用版本3.1版)不可或缺的组成部分,仅包含基于AT& T UNIX System V的TCP / IP的专有且非常不完整的实现Winsock的StreamsAPI。

Version 1.1 (winsock.h) of Winsock was supplied in an add-on package (called Wolverine) for Windows for Workgroups (code named Snowball). It was an integral component of Windows 95 and Windows NT from versions 3.5 and onwards (the initial commercially available version of Windows NT, version 3.1, included only a proprietary and quite incomplete implementation of TCP/IP based on the AT&T UNIX System V "Streams" API.

版本2.1 winsock2.h )在Windows 95的附加软件包中提供。它是Windows 98,Windows NT 4.0和所有后续Windows版本的不可或缺的组件。 Winsock 2.x的最新版本已随新的Windows版本或作为一部分提供服务包。

Version 2.1 (winsock2.h) of Winsock was supplied in an add-on package for Windows 95. It was an integral component of Windows 98, Windows NT 4.0, and all subsequent Windows releases. Recent versions of Winsock 2.x have been delivered with new Windows releases or as part of service packs.

Winsock 2可通过机制扩展称为分层服务提供程序(LSP).Winsock LSP可用于各种有用的目的,包括Internet父控制,Web内容过滤,QoS等。

Winsock 2 is extensible by a mechanism known as a Layered Service Provider (LSP). Winsock LSPs are available for a wide range of useful purposes, including Internet parental controls, web content filtering, QoS etc.

这篇关于WinSock.h&amp; WinSock2.h使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆