ECONNRESET 在 AF

编程入门 行业动态 更新时间:2024-10-28 12:24:33
本文介绍了ECONNRESET 在 AF_LOCAL 套接字的上下文中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道对于 TCP 套接字 ECONNRESET 与 RST 数据包有关.但是我在 read() 和 write() 调用上也看到了 AF_LOCAL 套接字的 ECONNRESET 错误.这是什么意思?ECONNRESET 与 read() 返回 0 或 write() 抛出 EPIPE 有何不同?

I understand that for TCP sockets ECONNRESET has got something to do with RST packets. But I've seen ECONNRESET errors for AF_LOCAL sockets too, on read() and write() calls. What does this mean? How is ECONNRESET different from read() returning 0 or write() throwing EPIPE?

推荐答案

看来 ECONNRESET 意味着对方已经关闭了连接,而没有读取已发送给它的未完成数据,并且可以在两个 read() 和写().但确切的行为取决于操作系统.

It would appear that ECONNRESET means that the other side has closed the connection without reading outstanding data that has been sent to it, and can be triggered on both read() and write(). But the exact behavior depends on the operating system.

似乎是在对已经关闭的套接字进行一次 write() 操作时触发的,并且没有未完成的传出数据.适用于 PF_LOCAL 和 TCP 套接字.示例(红宝石):

Seems to be triggered when one write()s to a socket that has already been closed, and there is no outstanding outgoing data. Applicable to both PF_LOCAL and TCP sockets. Example (Ruby):

a, b = UNIXSocket.pair b.close a.write("foo") # => EPIPE, on all OSes

read() 返回 0

当对方已经关闭连接,并且没有未完成的传出数据时触发.适用于 PF_LOCAL 和 TCP 套接字.

read() returning 0

Triggered when the other side has closed the connection, and there is no outstanding outgoing data. Applicable to both PF_LOCAL and TCP sockets.

a, b = UNIXSocket.pair b.close a.read # => 0 bytes, on all OSes

ECONNRESET

在 Linux 上它的行为是这样的:

ECONNRESET

On Linux it behaves like this:

当有尚未写入另一端的未完成的传出数据时触发.read() 为 PF_LOCAL 和 TCP 套接字触发它,但 write() 只为 TCP 套接字触发它;PF_LOCAL 套接字触发 EPIPE.

Triggered when there's outstanding outgoing data that has not yet been written to the other side. read() triggers it for both PF_LOCAL and TCP sockets, but write() triggers it only for TCP sockets; PF_LOCAL sockets trigger EPIPE.

查看特定操作系统行为的示例.如果您知道其他操作系统的行为方式,请贡献.

See examples for specific OS behavior. Please contribute if you know how other OSes behave.

示例 1:PF_LOCAL 套接字上的 read()

Example 1: read() on PF_LOCAL socket

a, b = UNIXSocket.pair a.write("hello") b.close a.read # Linux: ECONNRESET # OS X : returns 0 bytes

示例 2:TCP 套接字上的 read()

Example 2: read() on TCP socket

# Side A # Side B s = TCPServer.new('127.0.0.1', 3001) c = s.accept c = TCPSocket.new('127.0.0.1', 3001) c.write("hello") c.close c.read # Linux: ECONNRESET # OS X : returns 0 bytes

示例 3:PF_LOCAL 套接字上的 write()

Example 3: write() on PF_LOCAL socket

a, b = UNIXSocket.pair a.write("hello") b.close a.write("world") # Linux: EPIPE and not ECONNRESET # OS X : EPIPE and not ECONNRESET

示例 4:TCP 套接字上的 write()

Example 4: write() on TCP socket

# Side A # Side B s = TCPServer.new('127.0.0.1', 3001) c = s.accept c = TCPSocket.new('127.0.0.1', 3001) c.write("hello") c.close c.write("world") # Linux: ECONNRESET # OS X : no error

更多推荐

ECONNRESET 在 AF

本文发布于:2023-10-08 14:13:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ECONNRESET   AF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!