Excessive Delays in CAsyncSocket::Send()?
I've got an CDialog based application using a TCP connection. I'm using VS
2003 .NET. The application works as I expected using a software emulation
program on the same machine (via lookpack) or when connecting to the emulator
on another XP machine. So far so good.
When I connect with the target machine (some embedded Linux derivation),
CASyncSocket::Send() blocks for geometrically increasing times.
TRACE Output
Send in 0
Send in 250
Send in 578
Send in 1125
Send in 2329
Send in 4734
Send in 9547
Send in 0
....
I then run the application using Linux/Wine and everything is happy!
I'm setting the send buffer to zero to immediately send any message to the
target. (Volume of messages is low.)
int opt=0; // Force no buffering on send
if(!m_TCPClient->SetSockOpt(SO_SNDBUF, &opt, sizeof(opt))){
TRACE("SetSockOpt(m_TCPClient) failed with %d\n",::GetLastError());
}
SOCKADDR_IN server;
memset(&server,0,sizeof(server));
server.sin_family = AF_INET;
server.sin_addr.S_un.S_addr = pSock->sin_addr.S_un.S_addr;
server.sin_port = htons(LSP::LSP_PORT);
if(!m_TCPClient->Connect((SOCKADDR*)&server,sizeof(server))){
TRACE("TCPClient Connect failed w/%d\n",::GetLastError());
}
My send code is also fairly simple. I maintain a queue of messages and only
send after any previous message has been cleared.
(Everything is done in a single thread.)
DWORD dwNow = GetTickCount();
if(SOCKET_ERROR == m_TCPClient->Send(pPkt,pPkt->size())){
TRACE("m_TCPClient.Send() failed with %d\n",::GetLastError());
}
TRACE("Send in %d\n",GetTickCount()-dwNow);
I've experimented with TCP_NODELAY and differing values to SO_SNDBUF with
unsatisfactory results.
Any ideas on what's going on? The geomectrically increasing times should
mean something (just not to me).
Thanks in advance,
Steve