php sigpipe,Python的SIGPIPE信号「建议收藏」

php sigpipe,Python的SIGPIPE信号「建议收藏」Haveyoueverseenasocket.error:[Errno32]BrokenpipemessagewhenrunningaPythonWebserverandwonderedwhatthatmeans?Theruleisthatwhenaprocesstriestowritetoasocketthathasalre…

大家好,又见面了,我是你们的朋友全栈君。

Have you ever seen a socket.error: [Errno 32] Broken pipe message when running a Python Web server and wondered what that means?

The rule is that when a process tries to write to a socket that has already received an RST packet, the SIGPIPE signal is sent to that process which causes the Broken pipe socket.error exception.

Here are two scenarios that you can try that cause SIGPIPE signal to be fired.

1. Server may send an RST packet to a client to abort the socket connection but the client ignores the packet and continues to write to the socket.

To test that behavior. install Cynic, run it

CODE:01.$ cynic

02.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPHtmlResponse’   on port 2000

03.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPJsonResponse’   on port 2001

04.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPNoBodyResponse’ on port 2002

05.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPSlowResponse’   on port 2003

06.INFO     [2012-06-08 05:06:37,040] server: Starting ‘RSTResponse’        on port 2020

07.INFO     [2012-06-08 05:06:37,040] server: Starting ‘RandomDataResponse’ on port 2021

08.INFO     [2012-06-08 05:06:37,040] server: Starting ‘NoResponse’         on port 2022

09.INFO     [2012-06-08 05:06:37,041] server: Starting ‘LogRecordHandler’   on port /tmp/_cynic.sockand then run the client1.py:

CODE:01.import socket

02.

03.# connect to Cynic’s RSTResponse service on port 2020

04.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

05.s.connect((”, 2020))

06.

07.# first read gets an RST packet

08.try:

09.s.recv(1024)

10.except socket.error as e:

11.print e

12.print

13.

14.# write after getting the RST causes SIGPIPE signal

15.# to be sent to this process which causes a socket.error

16.# exception

17.s.send(‘hello’)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/301743/viewspace-733074/,如需转载,请注明出处,否则将追究法律责任。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/139298.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • VIF检验相关性「建议收藏」

    VIF检验相关性「建议收藏」VIF可以用来度量多重共线性问题,VIFj=11−Rj2\quad\mathrm{VIF}_{j}=\frac{1}{1-R_{j}^{2}}VIFj​=1−Rj2​1​式子中,Rj2R_{j}^{2}Rj2​是第jjj个变量在所有变量上回归时的确定系数。如果VIF过大(比如大于5或10),则意味着存在多重共线性问题。#数据df=pd.read_excel(io=’数据.xlsx’,sheet_name=0,usecols=range(1,5))#务必注意:一定要加上常数项,#如果没

    2022年4月28日
    141
  • pledge to_debezium采集 oracle

    pledge to_debezium采集 oracle下面我们来看两个范例,一个是使用BULKCOLLECT的,一个没有:范例1、使用多次循环来检索并显示数据。范例2、一次性获取数据,然后再循环显示。下面是一些有关BULKCOLLECT的建议:1、从Oracle9i开始,你都可以在静态SQL和动态SQL中使用BULKCOLLECT。2、你可以在任何地方的SELECTINTO,FETCHINTO,和RETURNINGINTO子句中使用BUL…

    2025年5月25日
    3
  • kali 换源教程

    一·寻找终端kali的终端类似于windows的dos,可以在此界面中,对kali系统进行操纵。其位于界面左侧,第三个图标便是终端。二·打开“sources.list“打开kali的终端输入命令“leafpad/etc/apt/sources.list“三·更改“sources.list“界面里所有内容全部删除,添加中科大的源。下面的就是中科大源的地址。debhttps:…

    2022年4月9日
    2.4K
  • zuul网关整合swagger

    zuul网关整合swaggerzuul整合swagger网关maven依赖<dependency><groupId>com.spring4all</groupId><artifactId>swagger-spring-boot-starter</artifactId><version>1.7.0.RELEASE</version></depende

    2022年8月15日
    5
  • W3C标准是_关于w3c标准下列说法错误的是

    W3C标准是_关于w3c标准下列说法错误的是W3C简介什么是W3C?万维网联盟(WorldWideWebConsortium)创建于1994年10月工作是对web进行标准化创建并维护WWW标准使用W3C的目的?为了让任何人在任何时间、任何地点、通过任何设备访问web内容。作为用户和浏览器制造商之间的中间层,要想办法满足下游的用户和上游不同浏览器看到的是同样的内容,让页面、程序能支持所有的浏览器,能够满足尽可能多的用户标准内容1、DOC…

    2025年12月13日
    2
  • 分组加密模式 ECB、CBC、PCBC、CFB、OFB、CTR

    在分组加密算法中,有几种不同的工作模式,分别是ECB(Electronic CodeBook,电子密码本模式)、CBC(Cipher-blockchaining,密码块连接模式)、PCBC(Propagatingcipher-blockchaining,填充密码块链接模式)、CFB(Cipherfeedback,密文反馈模式)、OFB(Outputfeedback,输出反馈模式)、CTR…

    2022年4月8日
    51

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号