推荐学习书目
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
sbmzhcn
V2EX  ›  Python

SocketServer self.request.sendall 与原生 socket.send 问题

  •  
  •   sbmzhcn · Dec 11, 2014 · 3015 views
    This topic created in 4239 days ago, the information mentioned may be changed or developed.
    class Server(ThreadingMixIn, TCPServer): pass

    server = Server(('', 8089), ThreadedTCPRequestHandler)
    server.serve_forever()

    class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):

    def handle(self):
    data = self.request.recv(1024)
    self.request.sendall(b'\x33\x34\x35')

    上面的self.request.sendall(b'\x33\x34\x35') 与

    connection, address = sock.accept()
    connection.send(b'\x33\x34\x35')

    有什么不同,为什么我用下面的socket.send是没有问题的,服务器能识别我发送的数据,但是最上面的那代码发送的数据就无法识别。为什么?

    都是发送一段16进制的代码,为什么一个可以,一个不可以,想请教是什么,搞了一天了也没有解决!!!
    ==
    sendall ,send, 都试了,一样的。
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   969 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:15 · PVG 05:15 · LAX 14:15 · JFK 17:15
    ♥ Do have faith in what you're doing.