[reSIProcate] Stun.cxx sleep code
- From: "Matthias Moetje - TERASENS GmbH" <moetje@xxxxxxxxxxxx>
- Date: Thu, 9 Mar 2006 01:02:06 +0100
Hi,
I just came across the following piece of code in
Stun.cxx:
sendMessage( myFd, buf, len, dest.addr, dest.port, verbose );
// add some delay so the packets don't get sent too quickly
#ifdef WIN32 // !cj! TODO - should fix this up in windows
clock_t now = clock();
assert( CLOCKS_PER_SEC == 1000 );
while ( clock() <= now+10 ) { };
#else
usleep(10*1000);
#endif
}
1. It seems that the code will cause a pause of 10ms
on Windows (with 100% CPU activity) and a pause of 10s
on all other platforms. On Windows Sleep(xx) could be
used, too.
2. Why is this pause needed at all? Afterwards a recvfrom
is usually done which blocks until reception anyway..
Any reasons for not removing the whole pause stuff?
Best regards,
Matthias Moetje