//設置超時
BOOL CClientSocket::SetTimeOut(UINT uTimeOut)
{
m_nTimerID = SetTimer(NULL,0,uTimeOut,NULL);
return m_nTimerID;
}
//取消設置超時
BOOL CClientSocket::KillTimeOut()
{
return KillTimer(NULL,m_nTimerID);
}
//用於CSocket函數阻塞時,若是超時,則退出該阻塞函數
BOOL CClientSocket::OnMessagePending()
{
MSG msg;
if(::PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_NOREMOVE)) {
if (msg.wParam == (UINT) m_nTimerID) {
::PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE);
CancelBlockingCall();
return FALSE;
};
};
return CSocket::OnMessagePending();
}