On 30 Apr, 19:55, Joseph M. Newcomer <newco...@flounder.com> wrote:
I've never had Connect fail to call OnConnect. You would have to show some code here. For
example, the code where you do the connection.
Here's the code from my async client. This happens to be in a UI thread.
joe
if(!m_socket.Create())
{ /* failed */
DWORD err = ::GetLastError();
ASSERT(target != NULL);
if(target != NULL)
target->PostMessage(UWM_NETWORK_ERROR, (WPARAM)err,
(LPARAM)::GetCurrentThreadId());
return FALSE;
} /* failed */
if(m_port == 0)
m_port = PORT_NUM; // default port number
// Try to connect to the peer
if (m_socket.Connect(m_ServerName, m_port) == 0)
{ /* connect failed */
DWORD err = ::GetLastError();
if (err != WSAEWOULDBLOCK)
{ /* serious failure */
//error in the connection process, terminate myself
ASSERT(target != NULL);
if(target != NULL)
target->PostMessage(UWM_NETWORK_ERROR, (WPARAM)err,
(LPARAM)::GetCurrentThreadId());
return FALSE;
} /* serious failure */
} /* connect failed */
On 30 Apr 2007 10:35:30 -0700, john wayne <attack...@yahoo.com> wrote:
I've a question for you. When I try to "connect" a CAsyncSocket in a
no blocked way I'm not able to get the connection. The OnConnect()
method is never called. If I block the socket I'm able to connect the
socket in a microsecond. Infact I block the socket only in that moment
and when I have the connection I unblock it. Have you another way on
how to connect a socket not blocking it?
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm
My code is exactly like your. "m_socket" is CAsyncSocket derivated? In
connection cannot be completed immediately" . OnConnect() is never
called after this. If I block the socket and connect it to server and