This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: clock() and sleep(int) system calls

Joe Clark wrote:
> Hello there.  I'm trying to build a socket-based program on WinNT 4, and
> I'd like to be able to combine clock() and sleep() in the program, but from
> my preliminary experiments, it appears that the sleep() function
> reinitializes the variable that clock() keeps track of -- so much for
> measuring elapsed time.  Is this documented somewhere?  Is there some good
> explanation for why it works this way?  Is there a way around it?
> While I'm at it, for those who know socket programming, is there a way to
> "kill" a call to the accept(...) function, which normally blocks until a
> connection comes in?  I'd like to declare a maximum time for my server to
> run (say 5 minutes), and then have it exit normally.

You have to use `select' to wait for a connection only a specific
amount of time. When select reports that a connection should be
established only then call `accept'.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer              
Red Hat, Inc.

Want to unsubscribe from this list?
Send a message to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]