exiting a loop

I am writing a socket program

bool done = false;
while(!done){
.
.
sck_client = accept(sck_unix, (struct sockaddr *)&remote, &len);
.
.
}

Is there anyway to interrupt this loop with the keyboard other than ctr-c and not stop the program but continue after the loop since the loop stalls at accept?
break;
You could read in a value at each iteration of the loop and tell the computer to stop if it detects an escape character being read in.

Alternately, if you wanted to cause it to check for keystrokes every iteration, and exit on a certain combination, you could do that as well. That would be a little more complex.
You're using blocking sockets, so the calls to socket functions will block until they complete.

If you want asynchronous behavious, you have to use non-blocking sockets. Look up select().
Topic archived. No new replies allowed.