OnConnect() 在什么时候被调用?
1
CAsyncSocket::OnConnect()
virtual void OnConnect( int nErrorCode );
Remarks
Called by the framework to notify this connecting socket that its connection attempt is completed, whether successfully or in error
函数被framework调用,表明正在连接的socket的连接意图已经完成,而不论连接
是不是成功
上面的翻译理解是不是对的呢?
我的理解是这样的:当调用了CAsyncSocket::Connect()函数后,在未来未知的时间里,framework将自动调用CAsyncSocket::OnConnect()
这样的理解对吗?
我测试了一下,设很多的断点,发现程序的流程不是很一致。
2
CAsyncSocket::OnReceive
virtual void OnReceive( int nErrorCode );
Called by the framework to notify this socket that there is data in the buffer that can be retrieved by calling the Receive member function. For more information, see the articleWindows Sockets: Socket Notifications in Visual C++ Programmer's Guide.
被framework调用,表明socket有data在buffer中,buffer可以通过调用Receive member function来得到。
理解:如果buffer中有data 的话,那么framework会调用CAsyncSocket::OnReceive。
这样的理解是不是对的呢?
CAsyncSocket::OnConnect()
virtual void OnConnect( int nErrorCode );
Remarks
Called by the framework to notify this connecting socket that its connection attempt is completed, whether successfully or in error
函数被framework调用,表明正在连接的socket的连接意图已经完成,而不论连接
是不是成功
上面的翻译理解是不是对的呢?
我的理解是这样的:当调用了CAsyncSocket::Connect()函数后,在未来未知的时间里,framework将自动调用CAsyncSocket::OnConnect()
这样的理解对吗?
我测试了一下,设很多的断点,发现程序的流程不是很一致。
2
CAsyncSocket::OnReceive
virtual void OnReceive( int nErrorCode );
Called by the framework to notify this socket that there is data in the buffer that can be retrieved by calling the Receive member function. For more information, see the articleWindows Sockets: Socket Notifications in Visual C++ Programmer's Guide.
被framework调用,表明socket有data在buffer中,buffer可以通过调用Receive member function来得到。
理解:如果buffer中有data 的话,那么framework会调用CAsyncSocket::OnReceive。
这样的理解是不是对的呢?
...全文
相关推荐
node-tms-onconnect:TMS OnConnect API的基于承诺的包装器
TMS OnConnect API 该库是Gracenote的TMS OnConnect API的简单包装。 每个方法都返回一个“ thenable”对象。用法该库建立在Bluebird之上,并大量使
java和as3 socket通信 解决安全沙箱问题
在AS3代码中,我们需要指定服务器的IP地址和端口,然后调用`connect()`方法建立连接。成功连接后,我们同样通过输入和输出流进行数据交换。
TP5-Linux(centos7)-Wokman+gateway.doc
```php<?phpdefine('APP_PATH', __DIR__ .
HarmonyOS应用开发-FA调用PA能力学习分享.docx
(Intent intent) { super.onConnect(intent); HiLog.info(LABEL_LOG, "onConnect"); } @Override protected
Video_Codec.rar_VFW传输_video_演示_视频 编码 解码_视频编码
包含OnConnect和OnReceive事件处理函数,成功连接时提示,接收数据时调用CClient


网络编程
