making a winsock listen loop in C
i'm wondering about this, for the purpose of server applications. every loop i've ever made to listen for connections utilizes close to 100% cpu because of constant conection checks.
basically i always end up with something like this (in psuedocode)
main {
pre configuration routines;
open socket for listening;
loop {
if (conection) {
dosomething
}
close socket;
post routines;
return;
}
how do i do this better, or how do i make it utilize less cpu resourcees? i'm good with C but am not familiar with the available windows API, so i don't really know about controlling cpu utilization via setting a variable or whatever.. please help
|