Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

사용법

#include <sys/types.h>
#include <sys/socket.h>

int recv(int s, void *buf, size_t len, int flags);

int  recvfrom(int  s, void *buf, size_t len, int flags, struct sockaddr
     *from, socklen_t *fromlen);

int recvmsg(int s, struct msghdr *msg, int flags);

설명

recvfromrecvmsg는 소켓(:12)으로 부터 메시지를 받기 위해서 사용하며, 연결지향(:12)소켓과 그렇지 않은 소켓 모두에 대해서 사용할 수 있다.

만약 from이 NULL이 아니고, 연결지향 소켓이 아니라면, 메시지의 source address가 채워진다. fromlen에는 sockaddr(:12)의 크기값이 넘어오게 된다.

recv는 단지 연결지향의 소켓에만 사용할 수 있으며, recvfrom에서 from인자를 NULL로 했을 때와 동일하다.