OnConnect() 在什么时候被调用?

TianGo123 TianGo123 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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。

这样的理解是不是对的呢?
...全文
评论 19
收藏 已收藏
分享
返回顶部
TianGo123
网络编程 18,356 成员 64,161 内容