Linux API/network
recv 와 read 차이
구차니
2023. 6. 23. 15:40
flag 안쓰면(NULL) 둘 다 거의 동일하다 라고 보면 될 듯.
The only difference between recv() and read(2) is the presence of flags. With a zero flags argument, recv() is generally equivalent to read(2) (but see NOTES). Also, the following call recv(sockfd, buf, len, flags); is equivalent to recvfrom(sockfd, buf, len, flags, NULL, NULL); NOTES If a zero-length datagram is pending, read(2) and recv() with a flags argument of zero provide different behavior. In this circumstance, read(2) has no effect (the datagram remains pending), while recv() con‐ sumes the pending datagram. The socklen_t type was invented by POSIX. See also accept(2). According to POSIX.1, the msg_controllen field of the msghdr structure should be typed as socklen_t, and the msg_iovlen field should be typed as int, but glibc currently types both as size_t. See recvmmsg(2) for information about a Linux-specific system call that can be used to receive multiple datagrams in a single call. |
[링크 : https://linux.die.net/man/2/recv]