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

相关文章

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

C#如何动态创建Label,及动态label事件

《C#如何动态创建Label,及动态label事件》:本文主要介绍C#如何动态创建Label,及动态label事件,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C#如何动态创建Label,及动态label事件第一点:switch中的生成我们的label事件接着,

SpringIntegration消息路由之Router的条件路由与过滤功能

《SpringIntegration消息路由之Router的条件路由与过滤功能》本文详细介绍了Router的基础概念、条件路由实现、基于消息头的路由、动态路由与路由表、消息过滤与选择性路由以及错误处理... 目录引言一、Router基础概念二、条件路由实现三、基于消息头的路由四、动态路由与路由表五、消息过滤

Tomcat版本与Java版本的关系及说明

《Tomcat版本与Java版本的关系及说明》:本文主要介绍Tomcat版本与Java版本的关系及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Tomcat版本与Java版本的关系Tomcat历史版本对应的Java版本Tomcat支持哪些版本的pythonJ

Java的IO模型、Netty原理解析

《Java的IO模型、Netty原理解析》Java的I/O是以流的方式进行数据输入输出的,Java的类库涉及很多领域的IO内容:标准的输入输出,文件的操作、网络上的数据传输流、字符串流、对象流等,这篇... 目录1.什么是IO2.同步与异步、阻塞与非阻塞3.三种IO模型BIO(blocking I/O)NI

基于Flask框架添加多个AI模型的API并进行交互

《基于Flask框架添加多个AI模型的API并进行交互》:本文主要介绍如何基于Flask框架开发AI模型API管理系统,允许用户添加、删除不同AI模型的API密钥,感兴趣的可以了解下... 目录1. 概述2. 后端代码说明2.1 依赖库导入2.2 应用初始化2.3 API 存储字典2.4 路由函数2.5 应

Nginx指令add_header和proxy_set_header的区别及说明

《Nginx指令add_header和proxy_set_header的区别及说明》:本文主要介绍Nginx指令add_header和proxy_set_header的区别及说明,具有很好的参考价... 目录Nginx指令add_header和proxy_set_header区别如何理解反向代理?proxy

JAVA SE包装类和泛型详细介绍及说明方法

《JAVASE包装类和泛型详细介绍及说明方法》:本文主要介绍JAVASE包装类和泛型的相关资料,包括基本数据类型与包装类的对应关系,以及装箱和拆箱的概念,并重点讲解了自动装箱和自动拆箱的机制,文... 目录1. 包装类1.1 基本数据类型和对应的包装类1.2 装箱和拆箱1.3 自动装箱和自动拆箱2. 泛型2

MySQL常见的存储引擎和区别说明

《MySQL常见的存储引擎和区别说明》MySQL支持多种存储引擎,如InnoDB、MyISAM、MEMORY、Archive、CSV和Blackhole,每种引擎有其特点和适用场景,选择存储引擎时需根... 目录mysql常见的存储引擎和区别说明1. InnoDB2. MyISAM3. MEMORY4. A

MyBatis的配置对象Configuration作用及说明

《MyBatis的配置对象Configuration作用及说明》MyBatis的Configuration对象是MyBatis的核心配置对象,它包含了MyBatis运行时所需的几乎所有配置信息,这个对... 目录MyBATis配置对象Configuration作用Configuration 对象的主要作用C