为编程爱好者分享易语言教程源码的资源网
雨云服务器 5 折购买
雨云服务器 · 5 折购买
稳定高速 · 新老用户同享 · 点击立即抢购
立即购买
AD广告招租 了解广告位详情 ›

网站首页 > 易语言相关 > 网络相关源码 正文

异步I/O模型下的WebSocket Client

三叶资源网 2021-08-06 11:16:14 网络相关源码 1467 ℃ 0 评论

前言:

最近写SOCC.js,封装到了WebSocket。

论坛上大部分的WebSocket Client基本都是同步Recv。

对于部分异步Recv,基本是调用封装的WebSocket Client(如HP-Socket)

于是我自己(面向MSDN编程)利用WSAAsyncSelect封装了一个异步的WebSocket Client

备注:

本程序的其他源码基础来自:[RFC 6455] WebSocket Client 模块纯源码实现以及分析

正文:

下面照抄MSDN对于WSAAsyncSelect的解释:

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不用再重新zc窗口消息。这给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。(虽然zc事件可以是同时多个事件,但是消息响应是一个一个来的。)


关于WSAAsyncSelect的一些解释:

参数“s”:A descriptor that identifies the socket for which event notification is required.(嵌套字标识符)

参数“hWnd”:A handle that identifies the window that will receive a message when a network event occurs.(接受消息的窗口句柄)

参数“wMsg”:A message to be received when a network event occurs.(事件发生时发给窗口的uMsg)

参数“lEvent”:A bitmask that specifies a combination of network events in which the application is interested.(监听的事件标识)


一些图片:

异步:

异步:

消息处理:

消息处理

文件下载
资源名称:异步I/O模型下的WebSocket Client


来源:三叶资源网,欢迎分享,公众号:iisanye,(三叶资源网⑤群:806035103 )

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 你 发表评论:

百度站内搜索
关注微信公众号
三叶资源网⑤群:三叶资源网官方群:806035103

网站分类
随机tag
动画源码图片拼接脚本引擎反汇编MP4视频文件ckplayer示例乐玩模拟器验证码图片脚本注册表操作多线程采集检测OD模块打印模块记牌器短网址接口销售记录系统哈罗单车客户端数据link配置器文件夹大小
最新评论
雨云服务器 · 5 折购买
稳定高速 · 新老用户同享 · 点击立即抢购
立即购买