반응형

 

동기 IO 멀티플렉싱 함수

synchronous I/O multiplexing

 

       int select(int nfds, fd_set *restrict readfds,
                  fd_set *restrict writefds, fd_set *restrict exceptfds,
                  struct timeval *restrict timeout);

readfds

읽기 준비되었는 지를 보기 위해, 관찰하려는 파일 디스크립터들이다.

 

writefds

쓰기 준비되었는 지를 보기 위해, 관찰하려는 파일 디스크립터들이다.

 

exceptfds

예외 조건을 위해 관찰하려는 파일 디스크립터들이다.

 

 

timeout

timeout을 NULL로 설정할 경우,

select()함수는 block한다. 즉, select()함수는 준비상태가 되기 위해 파일 디스크립터를 무한정 기다린다.

 

보통 아래처럼 쓰임

		if (select(maxfdp1, &read_fds, NULL, NULL, NULL) < 0) {
			printf("select error <= 0 \n");
			exit(0);
		}

 

반응형

'Linux > Linux' 카테고리의 다른 글

Netlink 정리  (0) 2023.01.06
[Linux] syscall 안에 들어가는 상수값들  (0) 2022.12.15
[Linux] 표준 에러 코드  (0) 2022.11.20
[Linux] xfrm command  (0) 2022.06.28
libnl, Netlink library에 대해  (0) 2022.06.25