Hi, I have problem with recv, but just on some computers. I have posted this thread somewhere else
because I have been thinking that it is a multithreading problem, but now after a lot more
information from debugging I know the exact place where it happens so I will put this one in
networking section better. Here in code, between check A2 and A3, is always exactly 515ms or 516ms,
EVEN THROUGH I set timeout with setsockopt as 1ms. It works on some comps, but some have problems and
give me this. I tried also to change timeout variable to something else, and it also does nothing -
it just adds that time to 515ms. I got rid of all another threads, so no - there is no switching to
something else. In this state it is a single-threaded app already. It happens on Acer Aspire One D250
(no extensions)+WinXP, and also it happens on virtual machine +Win7. I used also getsockopt to make
myself sure the timeout is written, and yes it is.
int myTcpSocket::XPrecieveMessage(string& message)
{
...stuff...
DWORD timeout = 1;
setsockopt(socketId, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
try
{printf("A%d\n",clock());
for(;;)
{printf("A2 %d\n",clock());
numBytes = recv(socketId,charMsg+received,1,0);printf("A3 %d\n",clock());
...stuff...
}printf("B%d\n",clock());
if(numBytes==6)
{...stuff...
}
}
catch(myException& excp)
{...stuff...
}
...stuff...
return msgSize;
}