error at the connect call it??s still working, i??m getting the WSAECONNREFUSED
onconnect when there??s no end point, and ok when there is. The problem is
"Joseph M. Newcomer" wrote:
See below...
On Fri, 28 Mar 2008 03:44:00 -0700, tabataa <tabataa@discussions.microsoft.com> wrote:
Hi,
I am migration a program running on Nt to XP, in NT everything works fine,
but in XP the connect call fails with a weird error (183), i catch the error
and continue with the execution as if it returns a WSAEWOULDBLOCK, when i get
the message in Onconnet (response time expired, the ip i am connecting to is
not connected) i close the socket and try again, but the next time i do the
create it crash with the same error (183)... the weird thing is that the same
code is perfectly running on NT.
Anybody?
Thanks in advance
int CClisock::NCreaSocket()
{
int nErr;
//creo el socket
if (Create( /*PORT_NUM, SOCK_STREAM,
FD_READ|FD_WRITE|FD_CONNECT|FD_CLOSE*/) == 0)
{
m_bConnected = FALSE;
m_bHaySock = FALSE;
return -1;
}
//me intento conectar para mantener una conexion establecida
if (Connect(m_sDirIp, PORT_NUM) == 0)
{
nErr = GetLastError();
****
What part of the documentation had you failed to read? The type of Connect is a BOOL, and
therefore comparing it to an integer is poor style. This would be properly written as
if(!Connect(m_sDirip, PORT_NUM))
*****
if (nErr != WSAEWOULDBLOCK)
{
m_pInfof->VInfof(INFO_ERR, "NCreaSocket Connect Err: %d", nErr);
VCierraSocket();
return -1;
}
}
m_bHaySock = TRUE;
return 1;
****
Is this supposed to indicate success? If so, why does it make sense if the connection
failed? You have not shown what you do if this function returns 1 (why is it not a BOOL
since it appears the only values it can return are success (1) and failure (-1)?).
You have not shown your OnConnect handler.
There is no way to tell from this example what is going on.
Are you saying nError==183 at the point where you call GetLastError()? Are you trying to
call Connect on the same IP address with the same port?
There's far too much missing to make sense of this.
joe
*****
}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm