socket 异步选择 WSAAsyncSelect 用法

简介: WSAAsyncSelect 实现给异步socket给了另一种实现方式,就是通过窗口消息的方式来提醒对socket接收还是发送 msdn有非常全面的解释:https://msdn.microsoft.

WSAAsyncSelect 实现给异步socket给了另一种实现方式,就是通过窗口消息的方式来提醒对socket接收还是发送

msdn有非常全面的解释:https://msdn.microsoft.com/en-us/library/windows/desktop/ms741540(v=vs.85).aspx

本文几解释以下我认为难懂的几点:

1.The socket created by the accept function has the same properties as the listening socket used to accept it. 
由listen socket 的accept返回的socket和listen的socket 具有同样的属性。意味着accept返回的socket不用再重新注册窗口消息。这给socket服务器提供了便利。

2.When one of the nominated network events occurs on the specified socket s, the application window hWndreceives message wMsg. The wParam parameter identifies the socket on which a network event has occurred. The low word of lParam specifies the network event that has occurred. The high word of lParam contains any error code. The error code be any error as defined in Winsock2.h.

wParam标识哪一个socket发生了事件,LOWWORD(lParam)表示当前发生的是哪个事件(是接收还是发送)  而HIWORD(lParam ) 标识错误代码

3.Although WSAAsyncSelect can be called with interest in multiple events, the application window will receive a single message for each network event。
虽然注册事件可以是同时多个事件,但是消息响应是一个一个来的。

下面附上我今天写的Socket 服务端。是由上一篇博文里的Server端修改而来。

 

附件下载

相关文章
|
11月前
|
Python
__name__的基本用法
__name__的基本用法
66 0
mailto用法详解
mailto用法详解
417 0
mailto用法详解
ClientToScreen 和ScreenToClient 用法
<div class="mod-page-main wordwrap clearfix"> <div class="x-page-container"> <div class="mod-blogpage-wraper"> <div class="grid-80 mod-blogpage"> <div class="mod-text-content mod-post-content
2940 0
|
C# 容器 数据格式
AvalonDock的基本用法
原文:AvalonDock的基本用法         AvalonDock是优秀的开源项目,用于创建可停靠式布局,能够在WPF中方便开发出类似VS2010的软件界面。对于复杂的软件系统,大量控件的使用会使的界面变得难以管理。
2051 0