其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
XP sp2对socket函数的影响

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

使用socket开发 的网络应用系统,在XP上运行的一向很好。现在移到新的机器上,新机器XP升级到sp2上,结果网络应用系统的服务器程序频繁出错,很奇怪。
后来经过跟踪发现,在新的环境中,recv函数发生了错误,虽然recv函数是阻塞的,但新的MSDN上说,recv及send函数在一些情况下会立即返回,并设置错误为WSAEWOULDBLOCK.。

下面是Microsoft的MSDN的 WSAAsyncSelect  API中说明:

As in the case of the select function, WSAAsyncSelect will frequently be used to determine when a data transfer operation (send or recv) can be issued with the expectation of immediate success. Nevertheless, a robust application must be prepared for the possibility that it can receive a message and issue a Windows Sockets 2 call that returns WSAEWOULDBLOCK immediately. For example, the following sequence of events is possible:

  1. Data arrives on socket s; Windows Sockets 2 posts WSAAsyncSelect message
  2. Application processes some other message
  3. While processing, application issues an ioctlsocket(s, FIONREAD...) and notices that there is data ready to be read
  4. Application issues a recv(s,...) to read the data
  5. Application loops to process next message, eventually reaching the WSAAsyncSelect message indicating that data is ready to read
  6. Application issues recv(s,...), which fails with the error WSAEWOULDBLOCK.

Other sequences are also possible.

The WS2_32.DLL will not continually flood an application with messages for a particular network event. Having successfully posted notification of a particular event to an application window, no further message(s) for that network event will be posted to the application window until the application makes the function call that implicitly reenables notification of that network event.

所以在网络应用中要检查是否错误并且是WSAEWOULDBLOCK,并进行相关处理。但在sp2之前居然都能正常使用。




相关文章

相关软件