objgraph无法生成分析图的原因
理解select模块--等待IO完成

socket.error: [Errno 32] Broken pipe错误的原因

妙音 posted @ 2014年1月26日 15:47 in python with tags socket , 16629 阅读
linux下的socket程序,尝试发送消息到已关闭的socket上,会出现此错误.
 
示例代码
服务端server.py
#encoding=utf-8
import socket
import time


def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(('0.0.0.0', 8050))
    sock.listen(5)

    client_sock, address = sock.accept()
    while True:
        msg = client_sock.recv(1024)
        print msg
        client_sock.send('from server: %s' % msg)
        time.sleep(1)
    client_sock.close()
    sock.close()


if __name__ == '__main__':
    main()
 
客户端client.py
#encoding=utf-8
import socket
import time


def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect(('0.0.0.0', 8050))
    while True:
        sock.send('hi')
        print sock.recv(1024)
        time.sleep(1)
    sock.close()


if __name__ == '__main__':
    main()
 
运行server.py和client.py,然后中断client.py会出现上面错误。
Avatar_small
LEGEND SEO 说:
2021年1月05日 16:05

Merely a smiling visitant here to share the love (:, btw outstanding style. movies 123

Avatar_small
Imamia Quran Academy 说:
2023年7月23日 05:57

Your blog provided us with valuable information to work with. Thanks a lot for sharing. I am from Imamia Quran Academy. Online Shia Quran Center provides you Shia Quranic education by the best scholars. Also, authentic Shia Quran translation and Shia Quran commentary are available for online users. Online users will be provided with the authentic experience of a regular Shia Quran Center without being physically present in certain premises.

Avatar_small
sharxs 说:
2023年12月07日 15:56

Indeks berita terkini dan terbaru hari ini dari peristiwa, kecelakaan, kriminal, hukum, berita unik, Politik, dan liputan khusus di Indonesia dan Internasional.

<a href="https://www.prepperdome.com/">https://www.prepperdome.com/</a>
<a href="https://www.kameraleder.com/">https://www.kameraleder.com/</a>
<a href="https://www.themooc.org/">https://www.themooc.org/</a>
<a href="https://lanternbooks.com/">https://lanternbooks.com/</a>
<a href="https://www.americandivecenter.com/">https://www.americandivecenter.com/</a>
<a href="https://pulpitocristao.com/">https://pulpitocristao.com/</a>
<a href="https://statiatourism.com/">https://statiatourism.com/</a>
<a href="https://tuomas-holopainen.com/">https://tuomas-holopainen.com/</a>
<a href="https://arrestedworld.com/">https://arrestedworld.com/</a>
<a href="https://askafreemason.org/">https://askafreemason.org/</a>
<a href="https://alphadeltacom.com/">https://alphadeltacom.com/</a>
<a href="https://revolvemerchandise.shop/">https://revolvemerchandise.shop/</a>
<a href="http://thelongestlistofthelongeststuffatthelongestdomainnameatlonglast.com/">http://thelongestlistofthelongeststuffatthelongestdomainnameatlonglast.com/</a>
<a href="https://allnewsweb.com/">https://allnewsweb.com/</a>
<a href="https://thenewcanadians.com/">https://thenewcanadians.com/</a>
<a href="https://cartografareilpresente.org/">https://cartografareilpresente.org/</a>
<a href="https://endthepainproject.org/">https://endthepainproject.org/</a>
<a href="https://www.stephenson-county-il.org/">https://www.stephenson-county-il.org/</a>
<a href="https://wii-brasil.com/">https://wii-brasil.com/</a>
<a href="https://athomeplate.com/">https://athomeplate.com/</a>
<a href="https://thecheaproute.com/">https://thecheaproute.com/</a>
<a href="https://www.stringbusters.com/">https://www.stringbusters.com/</a>
<a href="https://www.sausagesource.com/">https://www.sausagesource.com/</a>
<a href="https://steveroggenbuck.com/">https://steveroggenbuck.com/</a>
<a href="https://www.actioncarrental.com/">https://www.actioncarrental.com/</a>
<a href="https://www.mst3ktemple.com/">https://www.mst3ktemple.com/</a>
<a href="https://www.comediansusa.com/">https://www.comediansusa.com/</a>
<a href="https://www.fadwebsite.com/">https://www.fadwebsite.com/</a>
<a href="https://www.expocomic.com/">https://www.expocomic.com/</a>
<a href="https://www.nshp.org/">https://www.nshp.org/</a>
<a href="https://www.familiasunidasjusticia.org/">https://www.familiasunidasjusticia.org/</a>
<a href="https://www.bay-journal.com/">https://www.bay-journal.com/</a>
<a href="https://pubarticles.com/">https://pubarticles.com/</a>
<a href="https://ihearthu.com/">https://ihearthu.com/</a>
<a href="https://bestechvideos.com/">https://bestechvideos.com/</a>
<a href="https://swoodbridge.com/">https://swoodbridge.com/</a>
<a href="https://michiganyoutharts.org/">https://michiganyoutharts.org/</a>
<a href="https://crujonessociety.com/">https://crujonessociety.com/</a>
<a href="https://mustangdaily.net/">https://mustangdaily.net/</a>
<a href="https://midway.movie/">https://midway.movie/</a>
<a href="https://modmobilian.com/">https://modmobilian.com/</a>
<a href="https://lafriqueadulte.com/">https://lafriqueadulte.com/</a>
<a href="https://www.canosoarus.com/">https://www.canosoarus.com/</a>
<a href="https://scalingsocialbusiness.com/">https://scalingsocialbusiness.com/</a>
<a href="https://www.unitedwaytyr.com/">https://www.unitedwaytyr.com/</a>
<a href="https://blessedmariannecope.org/">https://blessedmariannecope.org/</a>
<a href="https://www.vanessahudgensofficial.com/">https://www.vanessahudgensofficial.com/</a>
<a href="https://www.outletmichaelkorsuk.co.uk/">https://www.outletmichaelkorsuk.co.uk/</a>
<a href="https://andotadao.org/">https://andotadao.org/</a>
<a href="https://www.monitortalent.com/">https://www.monitortalent.com/</a>

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter