int socket(int domain, int type, int protocol);
µµ¸ÞÀÎ ¸Å°³º¯¼ö´Â Åë½Å µµ¸ÞÀÎÀ» ÁöÁ¤ÇÑ´Ù; ÀÌ°ÍÀº Åë½Å¿¡ »ç¿ëµÇ¾î Áú ÇÁ·ÎÅäÄÝ Æйи®¸¦ ¼±ÅÃÇÑ´Ù. ÀÌ·¯ÇÑ ÇÁ·ÎÅäÄÝ Æйи®µéÀº <sys/socket.h> ¿¡¼ Á¤ÀǵȴÙ. ÇöÀç ¾²¿©Áö´Â Æ÷¸ËÀº ´ÙÀ½À» Æ÷ÇÔÇÑ´Ù:
Name:Purpose:Man page | ||
PF_UNIX,PF_LOCAL
|
Local communication
|
unix(7)
|
PF_INET
| IPv4 Internet protocols:T{ | |
T} | ||
PF_INET6
| IPv6 Internet protocols: | |
PF_IPX
| IPX - Novell protocols: | |
PF_NETLINK
|
Kernel user interface device
|
netlink(7)
|
PF_X25
| ITU-T X.25 / ISO-8208 protocol:T{ | |
T} | ||
PF_AX25
|
Amateur radio AX.25 protocol
| |
PF_ATMPVC
| Access to raw ATM PVCs: | |
PF_APPLETALK
| Appletalk:T{ | |
T} | ||
PF_PACKET
|
Low level packet interface
|
packet(7)
|
¼ÒÄÏÀº Áö½ÃµÈ Åë½Å semantics¸¦ ÁöÁ¤ÇÏ´Â type À» °®´Â´Ù. ÇöÀç Á¤ÀÇµÈ Å¸ÀÔÀº ´ÙÀ½°ú °°´Ù:
¸î¸î ¼ÒÄÏŸÀÔÀº ¸ðµç ÇÁ·ÎÅäÄݱº¿¡ ÀÇÇØ ±¸ÇöµÇ¾îÁöÁö ¾ÊÀ» °ÍÀÌ´Ù; ¿¹¸¦µé¸é, SOCK_SEQPACKET ´Â AF_INET ¶§¹®¿¡ ±¸ÇöµÇÁö ¾Ê´Â´Ù.
ÇÁ·ÎÅäÄÝ Àº ¼ÒÄÏÀ» »ç¿ëÇϱâ À§ÇØ Æ¯Á¤ ÇÁ·ÎÅäÄÝÀ» ÁöÁ¤ÇÑ´Ù. ½Ì±Û ÇÁ·ÎÅäÄÝÀº ÁÖ¾îÁø ÇÁ·ÎÅäÄݱº¾È¿¡ ƯÁ¤ ¼ÒÄÏŸÀÔÀ» Áö¿øÇϵµ·Ï Á¸ÀçÇÑ´Ù. ±×·¯³ª, ƯÁ¤ ÇÁ·ÎÅäÄÝÀÌ ¹æ¹ýÀ¸·Î ÁöÁ¤µÇ¾î¾ß¸¸ÇÏ´Â °÷¿£ ¸¹Àº ÇÁ·ÎÅäÄÝÀÌ Á¸Àç°¡´ÉÇÏ´Ù.
SOCK_STREAM ŸÀÔÀÇ ¼ÒÄÏÀº full-duplex byte streamsÀÌ´Ù. ±×°ÍµéÀº ·¹ÄÚµå °æ°è¸¦ º¸È£ÇÏÁø ¾Ê´Â´Ù. ½ºÆ®¸² ¼ÒÄÏÀº ¸ðµç µ¥ÀÌŸ°¡ ±×°ÍÀ¸·Î ¼Û¼ö½Å µÇ±âÀü¿¡ Á¢¼Ó »óÅÂÀ̾î¾ßÇÑ´Ù. ´Ù¸¥ ¼ÒÄÏ°úÀÇ Á¢¼ÓÀº connect(2) È£Ãâ·Î »ý¼ºÇÑ´Ù. Çѹø Á¢¼Ó¿¡ µ¥ÀÌŸ´Â read(2) ¿Í write(2) È£Ãâ ȤÀº send(2) ¿Í recv(2) È£Ãâ ÀÇ ¸î¸î º¯¼ö¸¦ »ç¿ëÇØ Àü¼ÛÇÑ´Ù. ¼¼¼ÇÀÌ ¿Ïº®ÇÒ¶§ close(2) ´Â ½ÇÇàµÈ´Ù. Out-of-band ¿¡ÀÌŸ´Â ¶ÇÇÑ send(2) ÀÇ ¼³¸í´ë·Î Àü¼ÛµÇ°í recv(2) ÀÇ ¼³¸í´ë·Î ¼ö½ÅµÈ´Ù.
SOCK_DGRAM ¿Í SOCK_RAW ¼ÒÄÏÀº send(2) È£Ãâ¿¡ ÁöÁ¤µÈ correspondents·Î µ¥ÀÌŸ±×·¥ÀÇ ¼Û½ÅÀ» Çã¶ôÇÑ´Ù. µ¥ÀÌŸ±×·¥Àº ´ë°³ ´ÙÀ½ µ¥ÀÌŸ±×·¥À» ¹ÝȯÇÏ´Â recvfrom(2) ·Î ¼ö½ÅµÈ´Ù.
SOCK_PACKET Àº ÀåÄ¡ µå¶óÀ̹ö·ÎºÎÅÍ Á÷Á¢ rawÆÐŶÀ» ¹Þ´Â ¾²ÀÌÁö ¾Ê´Â ¼ÒÄÏŸÀÔÀÌ´Ù. ´ë½Å packet(7) À» »ç¿ëÇÑ´Ù.
¼ÒÄÏÀÇ ÀÛ¿ëÀº ¼ÒÄÏ·¹º§ ¿É¼Ç¿¡ ÀÇÇØ Á¦¾îµÈ´Ù. ÀÌ·¯ÇÑ ¿É¼ÇµéÀº <sys/socket.h> ¿¡ Á¤ÀÇ µÇ¾îÀÖ´Ù. Setsockopt(2) ¿Í getsockopt(2) ´Â ¿É¼ÇÀ» ¼³Á¤ÇÏ°í ¾ò´Âµ¥ »ç¿ëµÈ´Ù.
´Ù¸¥ ¿¡·¯´Â ÇÁ·ÎÅäÄÝ ¸ðµâ¿¡ÀÇÇØ »ý¼ºµÈ´Ù.
lqAn Introductory 4.3 BSD Interprocess Communication Tutorialrq is reprinted in UNIX Programmer's Supplementary Documents Volume 1.
lqBSD Interprocess Communication Tutorialrq is reprinted in UNIX Programmer's Supplementary Documents Volume 1.