The Open Source Swiss Army Knife

/code/c/unix_c/select/
/code/c/unix_c/select/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /code   /c   /unix_c   /select 
Permalink: select.c
Title: basic select statement with fd_set and macros
article options : please login   |  raw source view  

#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

int main(){

	int retval=1;
	struct timeval tv;
	tv.tv_sec = 5;
	tv.tv_usec = 0;
	fd_set rfds;
	FD_ZERO(&rfds);
	FD_SET(1,&rfds);
	if ( (retval = select(2, &rfds, NULL, NULL, &tv)) != 0) {
		printf("data is available now");
		exit(0);
	} else {
		exit(0);
	}
}

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top