listen

LISTEN(2)                  Linux Programmer's Manual                 LISTEN(2)



NAME å称
       listen - listen for connections on a socket å¨ä¸ä¸ªå¥æ¥åä¸å¾å¬è¿æ¥

SYNOPSIS æ¦è¿°
       #include <sys/socket.h>

       int listen(int s, int backlog);

DESCRIPTION æè¿°
       å¨æ¥æ¶è¿æ¥ä¹å,é¦åè¦ä½¿ç¨ socket(2) å建ä¸ä¸ªå¥æ¥å,ç¶åè°ç¨ listen
       使å¶è½å¤èªå¨æ¥æ¶å°æ¥çè¿æ¥å¹¶ä¸ä¸ºè¿æ¥éåæå®ä¸ä¸ªé¿åº¦éå¶.
       ä¹åå°±å¯ä»¥ä½¿ç¨ accept(2) æ¥æ¶è¿æ¥.  listen è°ç¨ä»éç¨äº SOCK_STREAM æè
       SOCK_SEQPACKET ç±»åçå¥æ¥å.

       åæ° backlog æå®æªå®æè¿æ¥éåçæ大é¿åº¦.å¦æä¸ä¸ªè¿æ¥è¯·æ±å°è¾¾æ¶æªå®æè¿æ¥
       éå已满,é£ä¹å®¢æ·ç«¯å°æ¥æ¶å°é误 ECONNREFUSED.
       æè,å¦æä¸å±åè®®æ¯æéå,é£ä¹è¿ä¸ªè¿æ¥è¯·æ±å°è¢«å¿½ç¥,è¿æ ·å®¢æ·ç«¯
       å¨éè¯çæ¶åå°±ææåçæºä¼.

NOTES 注æ
       å¨TCPå¥æ¥åä¸ backlog çå«ä¹å¨Linux 2.2ä¸å·²ç»æ¹å.  å®æå®äºå·²ç»å®æè¿æ¥æ‐
       £çå¾åºç¨ç¨åºæ¥æ¶çå¥æ¥åéåçé¿åº¦,èä¸æ¯ æªå®æè¿æ¥çæ°ç®.æªå®æè¿æ¥å¥æ¥å‐
       éåçæ大é¿åº¦å¯ä»¥ä½¿ç¨ tcp_max_syn_backlog sysctl设置
       å½æå¼syncookiesæ¶ä¸åå¨é»è¾ä¸çæ大é¿åº¦,æ¤è®¾ç½®å°è¢«å¿½ç¥.åè§ tcp(7)
       以è·åæ´å¤ä¿¡æ¯.


RETURN VALUE è¿åå¼
       å½æ°æ§è¡æåæ¶è¿å0.é误æ¶è¿å-1,并置ç¸åºé误代ç .  errno

ERRORS é误
       EBADF  åæ° s ä¸æ¯åæ³çæ述符.

       ENOTSOCK
              åæ° s ä¸æ¯ä¸ä¸ªå¥æ¥å.

       EOPNOTSUPP
              å¥æ¥åç±»åä¸æ¯æ listen æä½.

CONFORMING TO å¼å®¹äº
       Single Unix, 4.4BSD, POSIX 1003.1g.  listen å½æ°è°ç¨æååºç°äº4.2BSD.

BUGS å误
       å¦æå¥æ¥åç±»åæ¯ AF_INET, 并ä¸åæ° backlog 大äºå¸¸é SOMAXCONN (Linux
       2.0&2.2ä¸æ¯128),å®å°è¢«èªå¨æªæ为 SOMAXCONN çå¼.
       æçBSDç³»ç»(以åä¸äºBSDæ©å±)å°backlogå¼éå¶ä¸º5.

SEE ALSO åè§
       accept(2), connect(2), socket(2)


[ä¸æçç»´æ¤äºº]
       byeyear <love_my_love@263.net >

[ä¸æçææ°æ´æ°]
       2002.01.27

ãä¸å½linux论åmanæå页翻è¯è®¡åã:
       http://cmpp.linuxforum.net

è·
       æ¬é¡µé¢ä¸æçç±ä¸æ man æå页计åæä¾ã
       ä¸æ man æå页计åï¼https://github.com/man-pages-zh/manpages-zh



BSD Man Page                     23 July 1993                        LISTEN(2)