recv

Autres langues

Langue: ja

Version: 2002-12-31 (openSuse - 09/10/07)

Section: 2 (Appels système)

̾Á°

recv, recvfrom, recvmsg - ¥½¥±¥Ã¥È¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¼è¤ë

½ñ¼°


#include <sys/types.h>


#include <sys/socket.h> ssize_t recv(int s, void *buf, size_t len, int flags); ssize_t recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); ssize_t recvmsg(int s, struct msghdr *msg, int flags);

ÀâÌÀ

recvfrom() ¤È recvmsg() ¥³¡¼¥ë¤Ï¡¢¥½¥±¥Ã¥È¤«¤é¥á¥Ã¥»¡¼¥¸¤ò¼õ¤±¼è¤ë¤Î¤Ë»ÈÍѤ¹¤ë¡£ ¤Þ¤¿¥½¥±¥Ã¥È¤Î¥Ç¡¼¥¿¼õ¿®¤Ë¤â»È¤¦¤³¤È¤¬¤Ç¤­¡¢ ¤³¤Î¤È¤­¥½¥±¥Ã¥È¤ÏÀܳ»Ø¸þ (connection-oriened) ¤Ç¤¢¤Ã¤Æ¤â¤Ê¤¯¤Æ¤â¤è¤¤¡£

from ¤¬ NULL °Ê³°¤Ç¡¢²¼ÁؤΥץí¥È¥³¥ë¤«¤éÁ÷¿®¸µ¥¢¥É¥ì¥¹¤¬Ê¬¤«¤ë¾ì¹ç¡¢ from ¤Ë¤Ï¤³¤ÎÁ÷¿®¸µ¥¢¥É¥ì¥¹¤¬Æþ¤ì¤é¤ì¤ë¡£ °ú¤­¿ô fromlen ¤ÏÆþ½ÐÎÏξÍѤΥѥé¥á¡¼¥¿¤Ç¡¢¸Æ¤Ó½Ð¤·»þ¤Ë¤Ï from ¤Ë³ä¤êÅö¤Æ¤¿¥Ð¥Ã¥Õ¥¡¤ÎÂ礭¤µ¤òÆþ¤ì¤Æ¤ª¤­¡¢Ê֤äƤ¯¤ë»þ¤Ë¤Ï¼ÂºÝ¤Ë from ¤Ë³ÊǼ¤µ¤ì¤¿¥¢¥É¥ì¥¹¤ÎÂ礭¤µ¤ËÊѹ¹¤µ¤ì¤ë¡£

recv() ¥³¡¼¥ë¤ÏÄ̾ï ÀܳºÑ¤ß¤Î (connected) ¥½¥±¥Ã¥È (connect(2) ¤ò»²¾È) ¤Ë¤Ä¤¤¤Æ¤Î¤ß»ÈÍѤµ¤ì¡¢ from ¥Ñ¥é¥á¡¼¥¿¤Ë NULL ¤ò»ØÄꤷ¤¿ recvfrom() ¤ÈÅù²Á¤Ç¤¢¤ë¡£

¤³¤ì¤é¤Î»°¤Ä¤Î¥ë¡¼¥Á¥ó¤Ï¤¤¤º¤ì¤â¡¢À®¸ù¤·¤¿¾ì¹ç¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤ÎŤµ¤òÊÖ¤¹¡£ ¥á¥Ã¥»¡¼¥¸¤¬Ä¹²á¤®¤Æ»ØÄꤵ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤ËÆþ¤êÀÚ¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢ ¥á¥Ã¥»¡¼¥¸¤ò¼õ¿®¤·¤¿¥½¥±¥Ã¥È¤Î¼ïÎà¤Ë¤è¤Ã¤Æ¤Ï;ʬ¤Î¥Ð¥¤¥È¤¬¼Î¤Æ¤é¤ì¤ë ¤«¤â¤·¤ì¤Ê¤¤¡£

¥½¥±¥Ã¥È¤Ë¼õ¤±¼è¤ë¥á¥Ã¥»¡¼¥¸¤¬Â¸ºß¤·¤Ê¤«¤Ã¤¿¾ì¹ç¡¢ ¼õ¿®ÍѤΥ³¡¼¥ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬ÅþÃ夹¤ë¤Þ¤ÇÂԤġ£ ¤¿¤À¤·¡¢¥½¥±¥Ã¥È¤¬ÈóÄä»ß (nonblocking) ¤ËÀßÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç (fcntl(2) ¤ò»²¾È) ¤Ï -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô errno ¤Ë EAGAIN ¤òÀßÄꤹ¤ë¡£ ¤³¤ì¤é¤Î¼õ¿®ÍѤΥ³¡¼¥ë¤Ï¡¢¼õ¿®¤·¤¿¥Ç¡¼¥¿¤Î¥µ¥¤¥º¤¬Í׵ᤷ¤¿¥µ¥¤¥º¤Ë 㤹¤ë¤Þ¤ÇÂԤĤΤǤϤʤ¯¡¢²¿¤é¤«¤Î¥Ç¡¼¥¿¤ò¼õ¿®¤¹¤ë¤ÈÉüµ¢¤¹¤ë (¼õ¿®¤µ¤ì¤ë¥Ç¡¼¥¿¤ÎºÇÂ祵¥¤¥º¤ÏÍ׵ᤷ¤¿¥µ¥¤¥º¤Ç¤¢¤ë)¡£

select(2) ¤ä poll(2) ¥³¡¼¥ë¤ò»È¤Ã¤Æ¡¢¼¡¤Î¥Ç¡¼¥¿¤¬¤¤¤ÄÆϤ¯¤«¤òȽÃǤǤ­¤ë¡£

recv() ¥³¡¼¥ë¤Î flags °ú¤­¿ô¤Ë¤Ï¡¢°Ê²¼¤ÎÃͤò 1¤Ä°Ê¾å¡¢¥Ó¥Ã¥Èñ°Ì¤Î OR (ÏÀÍýÏÂ) ¤ò¼è¤Ã¤¿¤â¤Î¤ò»ØÄꤹ¤ë:

MSG_DONTWAIT
ÈóÄä»ß (non-blocking) Áàºî¤òÍ­¸ú¤Ë¤¹¤ë¡£ Áàºî¤¬Ää»ß¤¹¤ë¤è¤¦¤Ê¾ì¹ç¤Ë EAGAIN ¤¬ÊÖ¤µ¤ì¤ë (fcntl(2) ¤Î F_SETFL ¤Ç O_NONBLOCK ¤ò»ØÄꤹ¤ë¤³¤È¤Ë¤è¤Ã¤Æ¤âÍ­¸ú¤Ë¤Ç¤­¤ë)¡£
MSG_ERRQUEUE
¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢ ¥­¥å¡¼¤ËÆþ¤ì¤é¤ì¤¿¥¨¥é¡¼¤ò¥½¥±¥Ã¥È¤Î¥¨¥é¡¼¥­¥å¡¼¤«¤é¼è¤ê¤À¤»¤ë¤è¤¦¤Ë¤Ê¤ë¡£ ¤³¤Î¥¨¥é¡¼¤ÏÊä½õ¥á¥Ã¥»¡¼¥¸¤ËÁȤ߹þ¤Þ¤ì¤ÆÅϤµ¤ì¡¢ ¤³¤ÎÊä½õ¥á¥Ã¥»¡¼¥¸¤Î¼ïÊ̤ϥץí¥È¥³¥ë¤Ë°Í¸¤¹¤ë (IPv4 ¤Î¾ì¹ç¤Ï IP_RECVERR)¡£ ¥æ¡¼¥¶¤Ï½½Ê¬¤Ê¥µ¥¤¥º¤Î¥Ð¥Ã¥Õ¥¡¤òÍÑ°Õ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ Êä½õ¥á¥Ã¥»¡¼¥¸¤Ë´Ø¤¹¤ë¤è¤ê¾ÜºÙ¤Ê¾ðÊó¤Ï cmsg(3) ¤ª¤è¤Ó ip(7) ¤ò»²¾È¤Î¤³¤È¡£ ¥¨¥é¡¼¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥ª¥ê¥¸¥Ê¥ë¥Ñ¥±¥Ã¥È¤Î¥Ú¥¤¥í¡¼¥É¤Ï¡¢ msg_iovec ·Ðͳ¤ÇÄ̾ï¤Î¥Ç¡¼¥¿¤È¤·¤ÆÅϤµ¤ì¤ë¡£ ¥¨¥é¡¼¤òµ¯¤³¤·¤¿¥Ç¡¼¥¿¥°¥é¥à¤Î¥ª¥ê¥¸¥Ê¥ë¤Î°¸À襢¥É¥ì¥¹¤Ï¡¢ msg_name ·Ðͳ¤Ç»²¾È¤Ç¤­¤ë¡£
¥í¡¼¥«¥ë¤Ê¥¨¥é¡¼¤Î¾ì¹ç¤Ï¥¢¥É¥ì¥¹¤ÏÅϤµ¤ì¤Ê¤¤ (¤³¤ì¤Ï cmsghdr ¤Î cmsg_len ¥á¥ó¥Ð¡¼¤Ç¥Á¥§¥Ã¥¯¤Ç¤­¤ë)¡£ ¼õ¿®¥¨¥é¡¼¤Î¾ì¹ç¤Ï MSG_ERRQUIE ¤¬ msghdr ¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£ ¥¨¥é¡¼¤¬ÅϤµ¤ì¤¿¸å¤Ë¤Ï¡¢¥­¥å¡¼¤ËÆþ¤Ã¤Æ¤¤¤ë¼¡¤Î¥¨¥é¡¼¤Ë´ð¤¤¤Æ¡¢ ½èÍýÂÔ¤Á¤Î¥½¥±¥Ã¥È¡¦¥¨¥é¡¼¤¬ºÆÀ¸À®¤µ¤ì¡¢¼¡¤Î¥½¥±¥Ã¥ÈÁàºî¤ÎºÝ¤ËÅϤµ¤ì¤ë¡£
¤³¤Î¥¨¥é¡¼¤Ï sock_extended_err ¹½Â¤ÂΤÇÄ󶡤µ¤ì¤ë:



#define SO_EE_ORIGIN_NONE    0

#define SO_EE_ORIGIN_LOCAL   1

#define SO_EE_ORIGIN_ICMP    2

#define SO_EE_ORIGIN_ICMP6   3



struct sock_extended_err

{

    u_int32_t ee_errno;   /* error number */

    u_int8_t  ee_origin;  /* where the error originated */

    u_int8_t  ee_type;    /* type */

    u_int8_t  ee_code;    /* code */

    u_int8_t  ee_pad;

    u_int32_t ee_info;    /* additional information */

    u_int32_t ee_data;    /* other data */

    /* More data may follow */

};



struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);

ee_errno ¤Ë¤Ï¥­¥å¡¼¤ËÆþ¤ì¤é¤ì¤¿¥¨¥é¡¼¤Î¥¨¥é¡¼Èֹ椬Æþ¤Ã¤Æ¤¤¤ë¡£ ee_origin ¤Ë¤Ï¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì½ê¤Î¥ª¥ê¥¸¥ó¡¦¥³¡¼¥É (origin code) ¤¬Æþ¤Ã¤Æ¤¤¤ë¡£ ¾¤Î¥Õ¥£¡¼¥ë¥É¤Ï¥×¥í¥È¥³¥ë°Í¸¤Ç¤¢¤ë¡£ SO_EE_OFFENDER ¥Þ¥¯¥í¤Ï¡¢¤³¤ÎÊä½õŪ¤Ê¥á¥Ã¥»¡¼¥¸¤ò°ú¤­¿ô¤Ë¼è¤Ã¤Æ¡¢ ¥¨¥é¡¼¤ÎȯÀ¸¤·¤¿¥Í¥Ã¥È¥ï¡¼¥¯¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥É¥ì¥¹¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ ¥¢¥É¥ì¥¹¤¬ÉÔÌÀ¤Î¾ì¹ç¤Ë¤Ï¡¢ sockaddr ¤Î sa_family ¥á¥ó¥Ð¡¼¤¬ AF_UNSPEC ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£ sockaddr ¤Î¾¤Î¥Õ¥£¡¼¥ë¥É¤ÏÉÔÄê¤Ç¤¢¤ë¡£ ¥¨¥é¡¼¤ÎȯÀ¸¤·¤¿¥Ñ¥±¥Ã¥È¤Î¥Ú¥¤¥í¡¼¥É¤ÏÄ̾ï¤Î¥Ç¡¼¥¿¤È¤·¤ÆÅϤµ¤ì¤ë¡£
¥í¡¼¥«¥ë¤Ç¤Î¥¨¥é¡¼¤Î¾ì¹ç¤Ë¤Ï¥¢¥É¥ì¥¹¤ÏÅϤµ¤ì¤Ê¤¤ (¤³¤ì¤Ï cmsghdr ¤Î cmsg_len ¥á¥ó¥Ð¡¼¤Ç¥Á¥§¥Ã¥¯¤Ç¤­¤ë)¡£ ¥¨¥é¡¼¤ò¼õ¤±¼è¤Ã¤¿¾ì¹ç¡¢ MSG_ERRQUEUE ¤¬ msghdr ¤ËÀßÄꤵ¤ì¤ë¡£ ¥¨¥é¡¼¤¬ÅϤµ¤ì¤¿¸å¤Ë¤Ï¡¢ ½èÍýÂÔ¤Á¤Ë¤Ê¤Ã¤Æ¤¤¤¿¥½¥±¥Ã¥È¡¦¥¨¥é¡¼¤¬¡¢¥­¥å¡¼¤ËÆþ¤Ã¤Æ¤¤¤ë ¼¡¤Î¥¨¥é¡¼¤Ë´ð¤Å¤¤¤ÆºÆÀ¸À®¤µ¤ì¡¢¼¡¤Î¥½¥±¥Ã¥ÈÁàºî¤ÎºÝ¤ËÅϤµ¤ì¤ë¡£
MSG_OOB
¤³¤Î¥Õ¥é¥°¤Ï¡¢Ä̾ï¤Î¥Ç¡¼¥¿¡¦¥¹¥È¥ê¡¼¥à¤Ç¤Ï¼õ¿®¤Ç¤­¤Ê¤¤ ÂÓ°è³° (out-of-band) ¥Ç¡¼¥¿¤Î¼õ¿®¤òÍ׵᤹¤ë¡£ ¥×¥í¥È¥³¥ë¤Ë¤è¤Ã¤Æ¤Ï¡¢ Ä̾ï¤Î¥Ç¡¼¥¿¡¦¥­¥å¡¼¤ÎÀèƬ¤Ë®ã¥Ç¡¼¥¿¤òÃÖ¤¯¤â¤Î¤¬¤¢¤ë¤¬¡¢ ¤½¤Î¤è¤¦¤Ê¥×¥í¥È¥³¥ë¤Ç¤Ï¤³¤Î¥Õ¥é¥°¤Ï»ÈÍѤǤ­¤Ê¤¤¡£
MSG_PEEK
¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤È¡¢ ¼õ¿®¥­¥å¡¼¤ÎºÇ½é¤Î¥Ç¡¼¥¿¤òÊÖ¤¹¤È¤­¡¢¥­¥å¡¼¤«¤é¥Ç¡¼¥¿¤òºï½ü¤·¤Ê¤¤¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢¤³¤Î¸å¤Ç¤â¤¦°ìÅÙ¼õ¿®¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤¹¤È¡¢Æ±¤¸¥Ç¡¼¥¿¤¬Ê֤뤳¤È¤Ë¤Ê¤ë¡£
MSG_TRUNC
¥Ñ¥±¥Ã¥È¤ÎŤµ¤¬ÅϤ·¤¿¥Ð¥Ã¥Õ¥¡¤è¤ê¤âŤ«¤Ã¤¿¾ì¹ç¤Ë¤â¡¢ ¥Ñ¥±¥Ã¥È¤Î¼ÂºÝ¤ÎŤµ¤òÊÖ¤¹¡£¥Ñ¥±¥Ã¥È¡¦¥½¥±¥Ã¥È¤ËÂФ·¤Æ¤Î¤ßÍ­¸ú¡£
MSG_WAITALL
¤³¤Î¥Õ¥é¥°¤Ï¡¢Í׵ᤷ¤¿Î̤¤¤Ã¤Ñ¤¤¤Î¥Ç¡¼¥¿¤¬ÅþÃ夹¤ë¤Þ¤Ç¡¢ Áàºî¤òÄä»ß (block) ¤¹¤ë¤è¤¦Í׵᤹¤ë¡£ ⤷¡¢¥·¥°¥Ê¥ë¤ò¼õ¿®¤·¤¿¤ê¡¢¥¨¥é¡¼¤äÀÚÃÇ (disconnect) ¤¬È¯À¸¤·¤¿¤ê¡¢ ¼¡¤Ë¼õ¿®¤µ¤ì¤ë¥Ç¡¼¥¿¤¬°Û¤Ê¤ë·¿¤À¤Ã¤¿¤ê¤·¤¿¾ì¹ç¤Ë¤Ï¡¢ Í׵ᤷ¤¿Î̤è¤ê¥Ç¡¼¥¿¤¬¾¯¤Ê¤¯¤Æ¤âÊ֤뤳¤È¤¬¤¢¤ë¡£

recvmsg() ¥³¡¼¥ë¤Ï¡¢Ä¾ÀÜÅϤ¹¥Ñ¥é¥á¡¼¥¿¤Î¿ô¤ò¸º¤é¤¹¤¿¤á¤Ë msghdr ¹½Â¤ÂΤò»ÈÍѤ¹¤ë¡£¤³¤Î¹½Â¤ÂÎ¤Ï <sys/socket.h> ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:




struct msghdr {

    void         *msg_name;       /* optional address */

    socklen_t     msg_namelen;    /* size of address */

    struct iovec *msg_iov;        /* scatter/gather array */

    size_t        msg_iovlen;     /* # elements in msg_iov */

    void         *msg_control;    /* ancillary data, see below */

    socklen_t     msg_controllen; /* ancillary data buffer len */

    int           msg_flags;      /* flags on received message */

};

msg_name ¤È msg_namelen ¤Ï¡¢¥½¥±¥Ã¥È¤¬Àܳ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤ËÁ÷¿®¸µ¤Î¥¢¥É¥ì¥¹¤ò»ØÄꤹ¤ë¡£ ̾Á°¤¬É¬Íפʤ¤¾ì¹ç¤Ë¤Ï msg_name ¤Ë NULL ¥Ý¥¤¥ó¥¿¤ò»ØÄꤹ¤ë¡£ msg_iov ¤È msg_iovlen ¥Õ¥£¡¼¥ë¥É¤Ï readv(2) ¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Êʬ²ò/·ë¹çÍѤΥ٥¯¥È¥ë (scatter-gather locations) ¤ò»ØÄꤹ¤ë¡£ msg_control ¥Õ¥£¡¼¥ë¥É¤Ï msg_controllen ¤ÎŤµ¤ò»ý¤Á¡¢Â¾¤Î¥×¥í¥È¥³¥ëÀ©¸æ¥á¥Ã¥»¡¼¥¸¤ä ¼ï¡¹¤ÎÊä½õ¥Ç¡¼¥¿¤Î¤¿¤á¤Î¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£ recvmsg() ¤ò¸Æ¤ÖºÝ¤Ë¤Ï¡¢ msg_controllen ¤Ë msg_control ¤Î¥Ð¥Ã¥Õ¥¡¤ÎŤµ¤òÆþ¤ì¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë¡£ ¥³¡¼¥ë¤¬À®¸ù¤·¤ÆÊ֤俾ì¹ç¡¢À©¸æ¥á¥Ã¥»¡¼¥¸Îó¤ÎŤµ¤¬Æþ¤Ã¤Æ¤¤¤ë¡£

¥á¥Ã¥»¡¼¥¸¤Î·Á¼°¤Ï°Ê²¼¤ÎÄ̤ê:




struct cmsghdr {

    socklen_t cmsg_len;     /* data byte count, including hdr */

    int       cmsg_level;   /* originating protocol */

    int       cmsg_type;    /* protocol-specific type */

/* followed by

    u_char    cmsg_data[]; */

};

Êä½õ¥Ç¡¼¥¿¤Ï¡¢ cmsg(3) ¤ËÄêµÁ¤µ¤ì¤¿¥Þ¥¯¥í·Ðͳ¤Ç¤Î¤ß¥¢¥¯¥»¥¹¤¹¤Ù¤­¤Ç¤¢¤ë¡£

Îã¤ò¤¢¤²¤ë¤È¡¢ Linux ¤Ï¤³¤ÎÊä½õ¥Ç¡¼¥¿¤Î¥á¥«¥Ë¥º¥à¤ò¡¢ Unix ¥½¥±¥Ã¥È¾å¤Ç¤Î³ÈÄ¥¥¨¥é¡¼¤ä IP ¥ª¥×¥·¥ç¥ó¡¢ ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¼õ¤±ÅϤ·¤ËÍøÍѤ·¤Æ¤¤¤ë¡£

msghdr ¤Î msg_flags ¥Õ¥£¡¼¥ë¥É¤Ï recvmsg() ¤«¤é¤Î¥ê¥¿¡¼¥ó»þ¤ËÀßÄꤵ¤ì¤ë¡£¤³¤³¤Ë¤Ï¤¤¤¯¤Ä¤«¤Î¥Õ¥é¥°¤¬Æþ¤ë¡£

MSG_EOR
¤³¤ì¤Ï¥ì¥³¡¼¥É¤Î½ª¤ê (end-of-record) ¤ò¼¨¤·¡¢ ÊÖ¤µ¤ì¤¿¥Ç¡¼¥¿¤¬´°Á´¤Ê¥ì¥³¡¼¥É¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹ (°ìÈÌŪ¤Ë¤Ï SOCK_SEQPACKET ·¿¤Î¥½¥±¥Ã¥È¤Ç»ÈÍѤµ¤ì¤ë)¡£
MSG_TRUNC
¥Ç¡¼¥¿¥°¥é¥à¤¬Í¿¤¨¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¤è¤êÂ礭¤«¤Ã¤¿¤¿¤á¤Ë¡¢ ¥Ç¡¼¥¿¥°¥é¥à¤Î¤Ï¤ß½Ð¤·¤¿Éôʬ¤¬¼Î¤Æ¤é¤ì¤¿¤³¤È¤ò¼¨¤¹¡£
MSG_CTRUNC
Êä½õ¥Ç¡¼¥¿¤Î¤¿¤á¤Î¥Ð¥Ã¥Õ¥¡¤¬ÉÔ­¤·¤¿¤¿¤á¤Ë¡¢ À©¸æ¥Ç¡¼¥¿¤Î°ìÉô¤¬¼Î¤Æ¤é¤ì¤¿¤³¤È¤ò¼¨¤¹¡£
MSG_OOB
®ã¥Ç¡¼¥¿¤äÂÓ°è³°¥Ç¡¼¥¿¤ò¼õ¿®¤·¤¿¤³¤È¤ò¼¨¤¹¡£
MSG_ERRQUEUE
¥Ç¡¼¥¿¤Ï¼õ¿®¤·¤Ê¤«¤Ã¤¿¤¬ ¥½¥±¥Ã¥È¤Î¥¨¥é¡¼¡¦¥­¥å¡¼¤«¤é³ÈÄ¥¥¨¥é¡¼¤ò¼õ¿®¤·¤¿¤³¤È¤ò¼¨¤¹¡£

ÊÖ¤êÃÍ

¤³¤ì¤é¤Î¥³¡¼¥ë¤Ï¼õ¿®¤·¤¿¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£ ¥¨¥é¡¼¤Î¾ì¹ç¤Ï -1 ¤òÊÖ¤¹¡£ ÀܳÀ褬Àµ¤·¤¯¥·¥ã¥Ã¥È¥À¥¦¥ó¤ò¼Â¹Ô¤·¤¿¾ì¹ç¤Ï¡¢ÊÖ¤êÃÍ¤Ï 0 ¤È¤Ê¤ë¡£

¥¨¥é¡¼

¤³¤ì¤é¤Ï¥½¥±¥Ã¥ÈÁؤÇȯÀ¸¤¹¤ë°ìÈÌŪ¤Ê¥¨¥é¡¼¤Ç¤¢¤ë¡£ ¾¤Î¥¨¥é¡¼¤¬²¼ÁؤΥץí¥È¥³¥ë¡¦¥â¥¸¥å¡¼¥ë¤ÇÀ¸À®¤µ¤ì¡¢ ÊÖ¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£ ¤½¤ì¤é¤Î¥Þ¥Ë¥å¥¢¥ë¤ò»²¾È¤¹¤ë¤³¤È¡£
EAGAIN
¥½¥±¥Ã¥È¤¬ÈóÄä»ß (non-blocking) ¤ËÀßÄꤵ¤ì¤Æ¤¤¤Æ ¼õ¿®Áàºî¤¬Ää»ß¤¹¤ë¤è¤¦¤Ê¾õ¶·¤Ë¤Ê¤Ã¤¿¤«¡¢ ¼õ¿®¤Ë»þ´ÖÀÚ¤ì (timeout) ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Æ ¥Ç¡¼¥¿¤ò¼õ¿®¤¹¤ëÁ°¤Ë»þ´ÖÀÚ¤ì¤Ë¤Ê¤Ã¤¿¡£
EBADF
°ú¤­¿ô s ¤¬ÉÔÀµ¤Ê¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤¢¤ë¡£
ECONNREFUSED
¥ê¥â¡¼¥È¤Î¥Û¥¹¥È¤Ç¥Í¥Ã¥È¥ï¡¼¥¯Àܳ¤¬µñÈݤµ¤ì¤¿ (¤è¤¯¤¢¤ëÍýͳ¤È¤·¤Æ¤Ï¡¢Í׵ᤷ¤¿¥µ¡¼¥Ó¥¹¤¬µ¯Æ°¤µ¤ì¤Æ¤¤¤Ê¤¤¤Ê¤É¤¬¤¢¤ë)¡£
EFAULT
¼õ¿®¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
EINTR
¥Ç¡¼¥¿¤ò¼õ¿®¤¹¤ëÁ°¤Ë¡¢¥·¥°¥Ê¥ë¤¬ÇÛÁ÷¤µ¤ì¤Æ³ä¤ê¹þ¤Þ¤ì¤¿¡£
EINVAL
ÉÔÀµ¤Ê°ú¤­¿ô¤¬ÅϤµ¤ì¤¿¡£
ENOMEM
recvmsg() ¤Î¤¿¤á¤Î¥á¥â¥ê¤¬³ÎÊݤǤ­¤Ê¤«¤Ã¤¿¡£
ENOTCONN
¥½¥±¥Ã¥È¤ËÀܳ»Ø¸þ¥×¥í¥È¥³¥ë¤¬³ä¤êÅö¤Æ¤é¤ì¤Æ¤ª¤ê¡¢ ¤Þ¤ÀÀܳ¤µ¤ì¤Æ¤¤¤Ê¤¤ (connect(2) ¤È accept(2) ¤ò»²¾È¤Î¤³¤È)¡£
ENOTSOCK
°ú¤­¿ô s ¤¬¥½¥±¥Ã¥È¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£

½àµò

4.4BSD (¤³¤ì¤é¤Î´Ø¿ô¤Ï 4.2BSD ¤Ç¸½¤ï¤ì¤¿), POSIX.1-2001¡£

POSIX.1-2001 ¤Ç¤Ï¡¢ MSG_OOB, MSG_PEEK, MSG_WAITALL ¥Õ¥é¥°¤À¤±¤¬µ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£

Ãí°Õ

¾åµ­¤Î¥×¥í¥È¥¿¥¤¥×¤Ï glibc2 ¤Ë¤·¤¿¤¬¤Ã¤Æ¤¤¤ë¡£ Single Unix Specification ¤Ç¤âƱÍͤÀ¤¬¡¢ ÊÖ¤êÃͤη¿¤¬ ssize_t ¤È¤Ê¤Ã¤Æ¤¤¤ë (°ìÊý¤Ç 4.x BSD ¤ä libc4 ¤ä libc5 ¤ÏÁ´¤Æ `int' ¤ò»ÈÍѤ·¤Æ¤¤¤ë)¡£ flags °ú¤­¿ô¤Ï 4.x BSD ¤Ç¤Ï `int' ¤À¤¬¡¢libc4 ¤È libc5 ¤Ç¤Ï `unsigned int' ¤Ç¤¢¤ë¡£ len °ú¤­¿ô¤Ï 4.x BSD ¤Ç¤Ï `int' ¤À¤¬¡¢ libc4 ¤È libc5 ¤Ç¤Ï `size_t' ¤Ç¤¢¤ë¡£ fromlen °ú¤­¿ô¤Ï 4.x BSD, libc4, libc5 ¤Ç¤Ï `int *' ¤Ç¤¢¤ë¡£ ¸½ºß¤Î `socklen_t *' ¤Ï POSIX ¤Çȯ°Æ¤µ¤ì¤¿¡£ accept(2) ¤â»²¾È¤¹¤ë¤³¤È¡£

POSIX.1-2001 ¤Ç¤Ï¡¢¹½Â¤ÂÎ msghdr ¤Î¥Õ¥£¡¼¥ë¥É msg_controllen ¤Ï socklen_t ·¿¤Ç¤¢¤ë¤Ù¤­¤À¤È¤µ¤ì¤Æ¤¤¤ë¤¬¡¢ ¸½ºß¤Î glibc (glibc 2.4) ¤Ç¤Ï size_t ·¿¤Ç¤¢¤ë¡£

Îã

recvfrom() ¤ÎÍøÍÑÎ㤬 getaddrinfo(3) ¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£

´ØÏ¢¹àÌÜ

fcntl(2), getsockopt(2), read(2), select(2), shutdown(2), socket(2), cmsg(3), sockatmark(3)