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)