Broken pipe 和 connection reset by peer
来源:互联网 发布:编程一小时网站 编辑:程序博客网 时间:2024/06/03 10:19
网络编程中,不慎就会掉入connection reset by peer或者broken pipe的坑中。主要是没有注意TCP的四次挥手。
connection reset by peer出现的主要原因是,某个套接口向一个已经关闭了的套接口写数据。典型的情况是,在C/S架构中,客户端突然崩溃,但是服务器端不知道客户端以及崩溃,如果此时服务器端向崩溃的客户端发送数据,则会出现connection reset by peer异常。其实这里的崩溃可以理解为客户端的套接口在向服务器端发送完请求后突然关闭,这时服务器端读取客户端的请求,并响应,但因为客户端发送完请求后就直接关闭了,因此对于服务器端的响应,客户机会返回一个reset报文,服务器端接收到这个报文,就会直接抛出connection reset by peer异常。
此时如果服务器继续向这个已经抛出异常的套接口写数据,套接口就会抛出broken pipe异常。
这个坑在使用epoll/select事件触发机制时要非常小心。因为当客户端的套接口关闭时,根据TCP的四次挥手,它会向服务器端发送一个FIN,而这个FIN会激活事件,如果这时不对收到的数据进行检查,查看收到的数据是否有效,直接向客户端写数据,那么就会报异常。
0 0
- Broken pipe 和 connection reset by peer
- 小实验:Broken pipe和Connection Reset by Peer
- 从tcp原理角度理解Broken pipe和Connection reset by peer的区别
- 从tcp原理角度理解Broken pipe和Connection reset by peer的区别
- 从tcp原理角度理解Broken pipe和Connection reset by peer的区别
- 从tcp原理角度理解Broken pipe和Connection Reset by Peer的区别
- 从tcp原理角度理解Broken pipe和Connection reset by peer的区别
- Connection reset by peer
- Connection reset by peer
- Connection reset by peer
- Connection reset by peer
- putty "connection reset by peer"
- ERROR:Connection reset by peer
- 再探Connection Reset By Peer
- Connection Reset By Peer 解析
- SocketException: Connection Reset by peer
- Connection reset by peer原因
- Connection reset by peer的原因
- 802.11N blockACK
- Spring 框架简介
- 欢迎使用CSDN-markdown编辑器
- 包含min函数的栈
- 计算机中丢失 msvcr110.dll 怎么办
- Broken pipe 和 connection reset by peer
- Leetcode-gas-station
- PHP current() 函数
- 342. Power of Four
- 换yum源
- Cocos2d-x开发系列 交叉开发模式五 绑定C++对象到Lua
- SPI详解
- Java基础——super的几种用法并与this的区别
- 数组中的逆序对