推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
YangJian1994
V2EX  ›  Python

我想问一下各位大佬,我最近用 Python 写了一个 socketserver(python3 版本),继承 socketserver.BaseRequestHandler,在 handle 函数里面写了一个 while 循环接受数据。

  •  1
     
  •   YangJian1994 · Jan 17, 2018 · 4737 views
    This topic created in 3213 days ago, the information mentioned may be changed or developed.

    def handle(self): connection = self.request while True: bytesData = connection.recv(1024) if not bytesData: break
    strData = byte2Hex(bytesData) print(strData)

    于是我用 TCP 工具去连接,并发送数据,服务端接受数据没问题,但是只要我断开 TCP 连接,服务端就会出现这个错误。ConnectionResetError:(Errno 104)Connection reset by peer,各位大佬帮忙看看。

    3 replies  •  2018-01-18 16:45:41 +08:00
    CEBBCAT
    CEBBCAT
    Jan 18, 2018 via Android
    1
    断开是 Ctrl + C 还是 name.close() ?
    hsuan
    hsuan
    Jan 18, 2018
    2
    你断开连接报 reset by peer 不是很正常吗?
    white1222
    white1222
    Jan 18, 2018
    3
    看着费眼
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2830 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:02 · PVG 21:02 · LAX 05:02 · JFK 08:02
    ♥ Do have faith in what you're doing.