2019. 7. 22. 17:44ㆍ임베디드/리눅스시스템프로그래밍
ssize_t read(int fd, void *buf, size_t count);
read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf. On files that support seeking, the read operation commences at the file offset, and the file offset is incremented by the number of bytes read. If the file offset is at or past the end of file, no bytes are read, and read() returns zero. If count is zero, read() may detect the errors described below. In the absence of any errors, or if read() does not check for errors, a read() with a count of 0 returns zero and has no other effects. According to POSIX.1, if count is greater than SSIZE_MAX, the result is implementation-defined; see NOTES for the upper limit on Linux
read API는 fd로부터 count 바이트만큼 읽어들인다. EOF에 도달하면 read는 0을 반환한다
TCP 서버에서 클라이언로 메세지를 보내 read API로 EOF까지 읽는 예제
'임베디드 > 리눅스시스템프로그래밍' 카테고리의 다른 글
wait와 waitpid (0) | 2019.07.23 |
---|---|
프로세스 생성 fork (0) | 2019.07.23 |
select (0) | 2019.07.01 |
I/O Multiplexing (0) | 2019.07.01 |
pthread_func의 반환값 (0) | 2019.06.13 |