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。
这样的理解是不是对的呢?