Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sockets 什么是';可能失败';什么意思?_Sockets_Network Programming_Unix Socket - Fatal编程技术网

Sockets 什么是';可能失败';什么意思?

Sockets 什么是';可能失败';什么意思?,sockets,network-programming,unix-socket,Sockets,Network Programming,Unix Socket,(手动3插座) 我最近遇到了这样一种情况,socket()返回一个非负fd,而对它的所有操作(accept(),connect())都将失败。此错误由valgrind--track fds=yes-v发现 这是否意味着即使socket()返回一个非负的fd,fd仍然可能无效?接受或连接时会出现什么错误?例如,如果没有fd,则初始套接字()调用可以工作,但由于accept()是另一个fd,它可能仍然会失败。@stdunbar valgrind输出“无效的fd 1022 for syscall so

(手动3插座)

我最近遇到了这样一种情况,
socket()
返回一个非负fd,而对它的所有操作(
accept()
connect()
)都将失败。此错误由
valgrind--track fds=yes-v
发现


这是否意味着即使
socket()
返回一个非负的
fd
fd
仍然可能无效?

接受或连接时会出现什么错误?例如,如果没有fd,则初始套接字()调用可以工作,但由于accept()是另一个fd,它可能仍然会失败。@stdunbar valgrind输出“无效的fd 1022 for syscall socket”,看起来达到了fd限制,但在某些情况下,connect也会失败。这有可能吗?(实际上我在高压下测试玩具服务器)socket()返回的非负fd将是有效的socket。它是否真的有用,OTOH,将取决于网络堆栈的状况等。如果它不起作用,那么事情一定出了很大的问题,不过:)
   The socket() function shall fail if:

   EAFNOSUPPORT
          The implementation does not support the specified address family.

   EMFILE All file descriptors available to the process are currently open.

   ENFILE No more file descriptors are available for the system.

   EPROTONOSUPPORT
          The protocol is not supported by the address family, or the protocol is not supported by the implementation.

   EPROTOTYPE
          The socket type is not supported by the protocol.

   The socket() function may fail if:

   EACCES The process does not have appropriate privileges.

   ENOBUFS
          Insufficient resources were available in the system to perform the operation.

   ENOMEM Insufficient memory was available to fulfill the request.