SOCKET

Section: Linux Programmer's Manual (2)
Updated: 24 Apr 1999
Index
Return to Main Contents
 

À̸§

socket - Åë½ÅÀ» À§ÇØ ¸»´Ü(endpoint)¸¦ »ý¼ºÇÑ´Ù.  

»ç¿ë¹ý

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

int socket(int domain, int type, int protocol);  

¼³¸í

Socket Àº Åë½ÅÀ» À§ÇÑ Á¾Á¡(endpoint)¸¦ »ý¼ºÇÏ°í µð½ºÅ©¸³Å͸¦ ¹ÝȯÇÑ´Ù.

µµ¸ÞÀÎ ¸Å°³º¯¼ö´Â Åë½Å µµ¸ÞÀÎÀ» ÁöÁ¤ÇÑ´Ù; ÀÌ°ÍÀº Åë½Å¿¡ »ç¿ëµÇ¾î Áú ÇÁ·ÎÅäÄÝ Æйи®¸¦ ¼±ÅÃÇÑ´Ù. ÀÌ·¯ÇÑ ÇÁ·ÎÅäÄÝ Æйи®µéÀº <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_DGRAM
µ¥ÀÌŸ±×·¥ Áö¿ø
SOCK_RAW
raw network protocol Á¢±Ù Áö¿ø.
SOCK_RDM
º¸ÁõÀ» ¿ä±¸ÇÏÁö ¾Ê´Â µ¥ÀÌŸ±×·¥ ·¹À̾îÁö¿ø.
SOCK_PACKET
»õ·Î¿î ÇÁ·Î±×·¥¿¡¼­ Àß ¾²ÀÌÁö ¾Ê´Â´Ù; packet(7) À» º»´Ù.

¸î¸î ¼ÒÄÏŸÀÔÀº ¸ðµç ÇÁ·ÎÅäÄݱº¿¡ ÀÇÇØ ±¸ÇöµÇ¾îÁöÁö ¾ÊÀ» °ÍÀÌ´Ù; ¿¹¸¦µé¸é, 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) ´Â ¿É¼ÇÀ» ¼³Á¤ÇÏ°í ¾ò´Âµ¥ »ç¿ëµÈ´Ù.  

¹Ýȯ°ª

¿¡·¯½Ã, -1ÀÌ ¹ÝȯµÈ´Ù; ±× ¹ÛÀÇ ¹Ýȯ°ªÀº µð½ºÅ©¸³ÅÍ ÂüÁ¶¼ÒÄÏÀÌ´Ù.  

¿¡·¯

EPROTONOSUPPORT
ÇÁ·ÎÅäÄÝ Å¸ÀÔÀ̳ª ÁöÁ¤µÈ ÇÁ·ÎÅäÄÝÀº ÀÌ µµ¸ÞÀο¡¼­ Áö¿øµÇÁö ¾Ê´Â´Ù.
ENFILE
»õ·Î¿î ¼ÒÄϱ¸Á¶¸¦ ÁöÁ¤Çϱ⿡ Ä¿³Î¸Þ¸ð¸®°¡ ºÎÁ·ÇÏ´Ù.
EMFILE
ÇÁ·Î¼¼½º ÆÄÀÏ Å×À̺íÀÌ overflow.
EACCES
ÁöÁ¤µÈ ŸÀÔÀÇ »ý¼ºµÈ ¼ÒÄÏÀ̳ª ÇÁ·ÎÅäÄÝ ±ÇÇÑÀÌ °ÅºÎµÇ¾ú´Ù.
ENOBUFS or ENOMEM
¸Þ¸ð¸®°¡ ºÎÁ·ÇÏ´Ù. ¼ÒÄÏÀº ÇÁ¸®¸Þ¸ð¸®°¡ »ý±æ¶§ ±îÁö »ý¼ºµÉ ¼ö ¾ø´Ù.
EINVAL
¾Ë·ÁÁöÁö ¾ÊÀº ÇÁ·ÎÅäÄÝÀ̳ª ÇÁ·ÎÅäÄݱºÀ¸·Î À¯È¿ÇÏÁö ¾Ê´Ù.

´Ù¸¥ ¿¡·¯´Â ÇÁ·ÎÅäÄÝ ¸ðµâ¿¡ÀÇÇØ »ý¼ºµÈ´Ù.  

ȣȯ

4.4BSD (the socket ÇÔ¼ö È£ÃâÀº 4.2BSD¿¡¼­ ¼±º¸¿´´Ù). ´ë°³ ºñ-bsd½Ã½ºÅÛ¿¡¼­´Â bsd¼ÒÄÏ·¹À̾îÀÇ Å¬·ÐÀ» Áö¿øÇÑ´Ù.  

¹ö±×

SOCK_UUCP ´Â ¾ÆÁ÷ ±¸ÇöµÇÁö ¾Ê¾Ò´Ù.  

°ü·Ã Ç׸ñ

accept(2), bind(2), connect(2), getprotoent(3), getsockname(2), getsockopt(2), ioctl(2), listen(2), read(2), recv(2), select(2), send(2), shutdown(2), socketpair(2), write(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.  

¿ªÀÚ

ASPLINUX, 2000³â 7¿ù 29ÀÏ


 

Index

À̸§
»ç¿ë¹ý
¼³¸í
¹Ýȯ°ª
¿¡·¯
ȣȯ
¹ö±×
°ü·Ã Ç׸ñ
¿ªÀÚ

This document was created by man2html, using the manual pages.
Time: 08:07:01 GMT, March 25, 2004