Socket编程:listen()函数英文翻译
链接:https://zhuanlan.zhihu.com/p/24951131
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
本篇翻译的listen()函数,我参考的国外网站是:
朋友们可以自由转载我对英文的中文翻译,但是对于“作者注:”的描述,转载时请注明出处和作者,否则视为侵权。
下面是翻译的正文,由于水平有限,有些翻译的不好,有些未能翻译出,恳请读者指出与见谅。
NAME
listen - listenfor socket connections and limit the queue of incoming connections
监听客户端发来的socket连接,而且限制接入的连接的队列。
SYNOPSIS
#include <sys/socket.h>
int listen(int socket,int backlog);
listen()函数原型。
DESCRIPTION
The listen() function marks aconnection-mode socket, specified by the
socket argument, as acceptingconnections, and limits the number of outstanding connections in the socket'slisten queue to the value specified by the
backlog argument.
这个listen()函数标记着一个处于连接模式的socket,也就是listen()函数的socket参数。listen()函数接收外来的连接,然后限制socket监听队列里的未完成的连接数量,限制的这个连接数量由参数backlog 指定。
作者注:
我觉得backlog 这个参数决定了listen()函数能处理多少个连接,超出这个连接数的话,listen()就不管了吧。
If listen() is called with a backlog argument valuethat is less than 0, the function sets the length of the socket's listen queueto 0.
如果传给listen()函数的backlog参数的值小于0,那么此函数会将socket的监听队列长度设置为0.
作者注:
给listen()函数传backlog参数时,肯定不会传给负数吧,这个可以人为控制的。
The implementationmay include incomplete connections in the queue subject to the queue limit. Theimplementation may also increase the specified queue limit internally if itincludes such incomplete connections in the queue subject to this limit.
由于容纳外来连接数量队列的限制,函数实现中也许包含连接队列中还有未完成的连接。后半句不知如何翻译。
Implementationsmay limit the length of the socket's listen queue. If backlog exceeds theimplementation-dependent maximum queue length, the length of the socket'slisten queue will be set to the maximum supported value.
函数实现也许会限制socket的监听队列长度。如果参数backlog超过了最大的队列长度,那么socket的监听队列的长度会被设置为最大的支持的值。
作者注:
服务器端能处理的客户端请求数量是有限的。服务器在处理一个客户端请求时,此时再来一个客户的请求,那么服务器就顾不上了,只能把新来的请求放在一个队列里。队列的长度是有限制的,超过这个限制的客户请求,可能就被丢弃吧。
The socket in usemay require the process to have appropriate privileges to use the
listen() function.
被使用的socket也许会要求进程有合适的权限来使用listen()函数。
RETURN VALUE
Upon successfulcompletions, listen() returns 0. Otherwise, -1 is returned and
errno is set to indicatethe error.
一旦listen()函数成功执行,函数会返回0,否则返回-1,而且会有错误信息来解释是什么错误。
ERRORS
The listen() function will failif:
函数listen()会由于以下原因失败:
[EBADF]
The socket argument is not avalid file descriptor.
参数socket不是一个有效的文件描述符。
[EDESTADDRREQ]
The socket is not bound to a localaddress, and the protocol does not support listening on an unbound socket.
socket没有被绑定到一个本地地址,协议也不支持在一个未绑定的socket上监听。
[EINVAL]
The socket is alreadyconnected.
socket已经处于连接中。
[ENOTSOCK]
The socket argument does notrefer to a socket.
参数socket没有引用到一个socket。
作者注:
参数socket是一个文件描述符,但是这个文件描述符没有引用到任何一个socket文件,形象的说,就是这个文件描述符指向了一个空空的东西。
[EOPNOTSUPP]
The socket protocol does not support listen().
socket协议不支持listen()函数。
The listen() function may failif:
函数listen()会由于以下原因可能会失败:
[EACCES]
The calling process does not have theappropriate privileges.
调用listen()函数的进程没有合适的权限。
[EINVAL]
The socket has been shutdown.
参数socket对应的套接字已经被关闭了。
[ENOBUFS]
Insufficient resources are available inthe system to complete the call.
系统中没有足够的资源来完成调用。
Socket编程:listen()函数英文翻译的更多相关文章
- socket编程listen函数限制连接数的解决方案
函数原型: int listen(int sockfd, int backlog); 当服务器编程时,经常需要限制客户端的连接个数,下面为问题分析以及解决办法: 下面只讨论TCP UDP不做讨论(很 ...
- Socket编程(C语言实现):socket()函数英文翻译
最近开始研究使用Socket API来网络编程,想着把自己的感想.感悟写下来.我发现在编程之外还有不少概念性的东西要学习.我觉得应该有以下几点吧: 1.得了解下计算机网络的基本概念,如OSI的7层模型 ...
- 网络编程socket之listen函数
摘要:listen函数使用主动连接套接口变为被连接套接口,使得一个进程可以接受其它进程的请求,从而成为一个服务器进程.在TCP服务器编程中listen函数把进程变为一个服务器,并指定相应的套接字变为被 ...
- Socket编程(C语言实现):bind()函数英文翻译
本篇翻译的bind()函数,我参考的国外网站是: bind 朋友们可以自由转载我对英文的中文翻译,但是对于"作者注:"的描述,转载时请注明出处和作者,否则视为侵权. 下面是翻译的正 ...
- php socket 编程读写函数
fwrite() 二进制安全 end条件[string写完/length-1]; fputs() fwrite()的别名; fread() 二进制安全,end条件[一个可用包/EOF/length-1 ...
- 转:Python 的 Socket 编程教程
这是用来快速学习 Python Socket 套接字编程的指南和教程.Python 的 Socket 编程跟 C 语言很像. Python 官方关于 Socket 的函数请看 http://docs. ...
- Python——Socket 编程教程
这是用来快速学习 Python Socket 套接字编程的指南和教程.Python 的 Socket 编程跟 C 语言很像. Python 官方关于 Socket 的函数请看 http://docs. ...
- Socket编程,C语言版!
socket编程--send函数&recv函数详解 一.send函数 ✍ 函数原型: int send( SOCKET s,char *buf,int len,int flags ); ✍ 功 ...
- socket编程中客户端常用函数
1 常用函数 1.1 connect() int connect(int sockfd, const struct sockaddr *servaddr, socklen_taddrlen); 客 ...
随机推荐
- Hive-分组之后取前n个
1. 统计国家每个省份出现次数最高的5个城市的名称 直观思维来考虑: 把 数据组织成: 国家 省份 出现次数(倒序) 城市 row_number() 根据partition by 生 ...
- Win8 Metro(C#)数字图像处理--2.46图像RGB分量增强效果
原文:Win8 Metro(C#)数字图像处理--2.46图像RGB分量增强效果 [函数名称] RGB分量调整 RGBAdjustProcess(WriteableBitmap ...
- 让bootstrap表格自动出现水平滚动条
<div class="table-responsive"><!--表格自动出现水平滚动条-> <table id="tb_departme ...
- tf.nn.softmax & tf.nn.reduce_sum & tf.nn.softmax_cross_entropy_with_logits
tf.nn.softmax softmax是神经网络的最后一层将实数空间映射到概率空间的常用方法,公式如下: \[ softmax(x)_i=\frac{exp(x_i)}{\sum_jexp(x_j ...
- C++没有库则寸步难行,有库则几乎可以做任何事情——Bjarne Stroustrupi
"Without a good library, most interesting tasks are hard to do in C++; but given a good library ...
- PE工具列表(看雪学院)
PE编辑工具 Stud_PE v. 2.6.0.5 Stud_PE v.2.6.1.0 (2.61汉化版) PE工具,用来学习PE格式十分方便. LordPE DLX增强版(2008.5.31) ...
- Uncaught (in promise)
Uncaught (in promise) 使用es6的promise时候,有时候会出现如下错误: 这是因为,使用定义promise方法的时候,reject了,但是,在使用的地方没有用catch进行接 ...
- 使用AnimateWindow来实现窗口淡入淡出(主要有四种动画,滚动,滑动,折叠或展开,和淡入淡出)
如果是在VC6下进行编译,应引入下面的预编译宏,注意放在windows.h的前面#undef WINVER #define WINVER 0x500为什么要引入上面的宏呢?看看winuse ...
- CMake编译Qt程序+UI+Resources
今天给大家讲解一下Cmake如何编译Qt程序. 这里说的Qt程序不只是用QtCreator写出来的程序,当然也可以是文本编辑器….这里说的Qt程序是指,QCoreApplication,QApplic ...
- 创业游戏模拟器 Startup 游戏试玩
买的正版游戏,还在beta阶段.因为对这种经营类的游戏挺感兴趣,结合自己也是做这个行当的.算是一次性通关了吧.我来评价一下这个游戏.足足玩了有5个多小时.从1级玩到15级.解锁了所有的内容.员工从1个 ...