|
-
November 27th, 2003, 10:39 PM
#9
By the way, I have a problem. I use MFC Socket class: CAsynSocket. I want to check connection status with the lowest cost.
- Whenever call connect, return value will reveal connection status.
- Whenever WM_CLOSE is notified, connection status is updated.
But my problem is that CAsynSocket::Connect always return WSAEWOULDBLOCK even server exists or do not.
So my solution is that I derived CAsyncSocket::Connect where I call Connect twice continuously. The last return value will be the desired value. It works well in WinXP. In Win2000, or Win98, some time my Connect() implementation raise error.
Anyone has a idea? Thanks. Here is my snippet code:
m_bConnect = CAsyncSelect::Connect( m_strServerIP, m_nServerPort);
m_bConnect = CAsyncSelect::Connect( m_strServerIP, m_nServerPort);
DWORD dwError = GetLastError();
if( m_bConnect || (dwError == WSAEISCONN) )
{
m_bConnect = TRUE;
return TRUE;
}else
{
m_bConnect = FALSE;
}
Quang
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|