/*
 * Illustrating example of how bits are stored in fd_set, select(2)
 *
 * by Hans Schou 2004.
 */

#include <stdio.h>
#include <sys/types.h>
#include <termios.h>
#include <stdlib.h>

int main( void ) {
	fd_set readset;
	char *p = (char *)&readset;
	int i = 0;

	printf("sizeof(readset): %d\n", sizeof(readset));
	printf("Number of bits in readset: %d\n", sizeof(readset)*8);

	FD_ZERO(&readset);
	FD_SET(0,&readset); /* == 01 */
	FD_SET(9,&readset); /* == 02 */

	while (i++<sizeof(readset)) {
		printf("%02x ", *p++);
	}
	printf("\n");


	return EXIT_SUCCESS;
}

