Created
March 9, 2012 18:48
-
-
Save rudimeier/2008021 to your computer and use it in GitHub Desktop.
simple code for testing select behaviour on MacOSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <sys/select.h> | |
int main(int argc, char *argv[]) | |
{ | |
int nfds = (argc > 1) ? atoi(argv[1]) : 0; | |
struct timeval tval; | |
tval.tv_usec = 100 * 1000; | |
tval.tv_sec = 0; | |
if( select(nfds, NULL, NULL, NULL, &tval) < 0 ) { | |
printf("select NULL failed: %s.\n", strerror(errno)); | |
} | |
fd_set readSet, writeSet; | |
FD_ZERO( &readSet); | |
FD_ZERO( &writeSet); | |
if( select(nfds, &readSet, &writeSet, NULL, &tval) < 0 ) { | |
printf("select ZERO failed: %s.\n", strerror(errno)); | |
} | |
printf("finito\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment