WinSock IO模型 -- WSAEventSelect模型事件触发条件说明

2024-03-23 11:18

本文主要是介绍WinSock IO模型 -- WSAEventSelect模型事件触发条件说明,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.         FD_READ事件

l  调用WSAEventSelect函数时,如果当前有数据可读

l  有数据到达时,并且没有发送过FD_READ事件

l  调用recv/recvfrom函数后,仍然有数据可读时

2.         RD_WRITE事件

l  调用WSAEventSelect函数时,如果调用能够发送数据时

l  调用connect()/accept()后,连接已经建立时

l  调用send()/sendto()函数后,返回WSAEWOULDBLOCK错误后,再次调用send()/sendto()函数可能成功时

3.         FD_ACCEPT事件

l  调用WSAEventSelect函数时,有连接请求需要建立

l  连接请求到达,未有发送FD_ACCEPT事件

l  调用accept()函数后,还有连接请求需要建立

4.         FD_CONNECT事件

l  调用WSAEventSelect函数时,一个连接已经建立完成

l  调用connect()函数后,建立连接完成时

5.         FD_CLOSE事件

l  调用WSAEventSelect函数时,socket连接关闭

l  从容关闭,没有数据可读

l  执行shutdown()从容关闭,对方应答FIN后,无数据需要读取

l  对方关闭连接,WSAECONNRESET错误发生

 

 

 

 

 

Network Event description from MSDN. Good details for each event.

-----------------------------------------------------------------

Here is a summary of events and conditions for each asynchronous notification message.

 

 

  • FD_READ:
    1. When WSAAsyncSelect is called, if there is data currently available to receive.
    2. When data arrives, if FD_READ is not already posted.
    3. After recv or recvfrom is called, with or without MSG_PEEK), if data is still available to receive.

      Note  When setsockopt SO_OOBINLINE is enabled, data includes both normal data and OOB data in the instances noted above.

  • FD_WRITE:
    1. When WSAAsyncSelect called, if a send or sendto is possible.
    2. After connect or accept called, when connection established.
    3. After send or sendto fail with WSAEWOULDBLOCK, when send or sendto are likely to succeed.
    4. After bind on a connectionless socket. FD_WRITE may or may not occur at this time (implementation-dependent). In any case, a connectionless socket is always writeable immediately after a bind operation.
  • FD_OOB: Only valid when setsockopt SO_OOBINLINE is disabled (default).
    1. When WSAAsyncSelect called, if there is OOB data currently available to receive with the MSG_OOB flag.
    2. When OOB data arrives, if FD_OOB not already posted.
    3. After recv or recvfrom called with or without MSG_OOB flag, if OOB data is still available to receive.
  • FD_ACCEPT:
    1. When WSAAsyncSelect called, if there is currently a connection request available to accept.
    2. When a connection request arrives, if FD_ACCEPT not already posted.
    3. After accept called, if there is another connection request available to accept.
  • FD_CONNECT:
    1. When WSAAsyncSelect called, if there is currently a connection established.
    2. After connect called, when connection is established, even when connect succeeds immediately, as is typical with a datagram socket.
    3. After calling WSAJoinLeaf, when join operation completes.
    4. After connect, WSAConnect, or WSAJoinLeaf was called with a nonblocking, connection-oriented socket. The initial operation returned with a specific error of WSAEWOULDBLOCK, but the network operation went ahead. Whether the operation eventually succeeds or not, when the outcome has been determined, FD_CONNECT happens. The client should check the error code to determine whether the outcome was successful or failed.
  • FD_CLOSE: Only valid on connection-oriented sockets (for example, SOCK_STREAM)
    1. When WSAAsyncSelect called, if socket connection has been closed.
    2. After remote system initiated graceful close, when no data currently available to receive (Be aware that, if data has been received and is waiting to be read when the remote system initiates a graceful close, the FD_CLOSE is not delivered until all pending data has been read).
    3. After local system initiates graceful close with shutdown and remote system has responded with "End of Data" notification (for example, TCP FIN), when no data currently available to receive.
    4. When remote system terminates connection (for example, sent TCP RST), and lParam will contain WSAECONNRESET error value.

      Note  FD_CLOSE is not posted after closesocket is called.

  • FD_QOS:
    1. When WSAAsyncSelect called, if the quality of service associated with the socket has been changed.
    2. After WSAIoctl with SIO_GET_QOS called, when the quality of service is changed.
  • FD_GROUP_QOS: Reserved.
  • FD_ROUTING_INTERFACE_CHANGE:
    •  
      • After WSAIoctl with SIO_ROUTING_INTERFACE_CHANGE called, when the local interface that should be used to reach the destination specified in the IOCTL changes.
  • FD_ADDRESS_LIST_CHANGE:
    •  
      • After WSAIoctl with SIO_ADDRESS_LIST_CHANGE called, when the list of local addresses to which the application can bind changes.

这篇关于WinSock IO模型 -- WSAEventSelect模型事件触发条件说明的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/838144

相关文章

Go语言中make和new的区别及说明

《Go语言中make和new的区别及说明》:本文主要介绍Go语言中make和new的区别及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1 概述2 new 函数2.1 功能2.2 语法2.3 初始化案例3 make 函数3.1 功能3.2 语法3.3 初始化

java中新生代和老生代的关系说明

《java中新生代和老生代的关系说明》:本文主要介绍java中新生代和老生代的关系说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、内存区域划分新生代老年代二、对象生命周期与晋升流程三、新生代与老年代的协作机制1. 跨代引用处理2. 动态年龄判定3. 空间分

MySQL之InnoDB存储引擎中的索引用法及说明

《MySQL之InnoDB存储引擎中的索引用法及说明》:本文主要介绍MySQL之InnoDB存储引擎中的索引用法及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录1、背景2、准备3、正篇【1】存储用户记录的数据页【2】存储目录项记录的数据页【3】聚簇索引【4】二

mysql中的数据目录用法及说明

《mysql中的数据目录用法及说明》:本文主要介绍mysql中的数据目录用法及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、背景2、版本3、数据目录4、总结1、背景安装mysql之后,在安装目录下会有一个data目录,我们创建的数据库、创建的表、插入的

Maven中的profiles使用及说明

《Maven中的profiles使用及说明》:本文主要介绍Maven中的profiles使用及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录主要用途定义 Profiles示例:多环境配置激活 Profiles示例:资源过滤示例:依赖管理总结Maven 中的

Before和BeforeClass的区别及说明

《Before和BeforeClass的区别及说明》:本文主要介绍Before和BeforeClass的区别及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Before和BeforeClass的区别一个简单的例子当运行这个测试类时总结Before和Befor

Python pip下载包及所有依赖到指定文件夹的步骤说明

《Pythonpip下载包及所有依赖到指定文件夹的步骤说明》为了方便开发和部署,我们常常需要将Python项目所依赖的第三方包导出到本地文件夹中,:本文主要介绍Pythonpip下载包及所有依... 目录步骤说明命令格式示例参数说明离线安装方法注意事项总结要使用pip下载包及其所有依赖到指定文件夹,请按照以

SQL中JOIN操作的条件使用总结与实践

《SQL中JOIN操作的条件使用总结与实践》在SQL查询中,JOIN操作是多表关联的核心工具,本文将从原理,场景和最佳实践三个方面总结JOIN条件的使用规则,希望可以帮助开发者精准控制查询逻辑... 目录一、ON与WHERE的本质区别二、场景化条件使用规则三、最佳实践建议1.优先使用ON条件2.WHERE用

如何解决Druid线程池Cause:java.sql.SQLRecoverableException:IO错误:Socket read timed out的问题

《如何解决Druid线程池Cause:java.sql.SQLRecoverableException:IO错误:Socketreadtimedout的问题》:本文主要介绍解决Druid线程... 目录异常信息触发场景找到版本发布更新的说明从版本更新信息可以看到该默认逻辑已经去除总结异常信息触发场景复

Spring中管理bean对象的方式(专业级说明)

《Spring中管理bean对象的方式(专业级说明)》在Spring框架中,Bean的管理是核心功能,主要通过IoC(控制反转)容器实现,下面给大家介绍Spring中管理bean对象的方式,感兴趣的朋... 目录1.Bean的声明与注册1.1 基于XML配置1.2 基于注解(主流方式)1.3 基于Java