si*****@gmail.com wrote:
Hello,
I have a counter loop which actually executes in a different thread.
The thread is there to check for a connection time out. However due to
some limitations, I cannot use pthreads or any OS dependant components
(my code should run on both windows and linux). I have to relegiously
stick on to ANSIC standard.
If it's only Windows and platforms w/ POSIX threads (including Linux), then
this might help:
http://sources.redhat.com/pthreads-win32/
Does ANSI C provide any inherent function which could accomplish what I
intend to do. Or putting it otherway, how can I just deviate from my
direct execution path and just return to it after a stipulated time has
elapsed.
Not in ISO C, though I strongly suspect that if you're blocked on a
"connect" that you're already using another set of interfaces. In that case
the right answer for this particular problem couldn't be in ISO C, and
trying to stick too closely to ISO--within the scope of this particular
problem--will probably create more problems than benefits.
When it comes to networking, the next level up in standards is POSIX. You
can generally find POSIX interfaces for Windows (as in the above example).
Ultimately you could always bundle cygwin.dll with your application:
http://www.cygwin.com/