如果我在Flask上编码,那么我有时会收到此错误:
Traceback (most recent call last):
File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python27\lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python27\lib\SocketServer.py", line 640, in __init__
self.finish()
File "C:\Python27\lib\SocketServer.py", line 693, in finish
self.wfile.flush()
File "C:\Python27\lib\socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10053] ????????? ?? ????? ????-
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会发生这种情况(win8 x64,python27 x32)?
差不多2天我仍然有同样的问题 - 客户端和服务器"对话",但我不知道为什么在通信过程中突然出现问题.我尝试了很多东西,不幸的是仍然是同样的问题.
我在Windows 7上使用python 2.7.5.
我的代码: cs_common.py
import socket
import os
import sys
import errno
from time import sleep
HOST = 'localhost'
MY_IP = socket.gethostbyname(socket.gethostname())
PORT = 50007
timeout_in_seconds = 2
def createSocket4server(host, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(4)
return s
def createSocket4Client(host, port, timeout_in_seconds=3):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect( (host, port) )
print 'connected to %s port %s' % (host, port)
return s
sent = 0
def sendToSocket(socket_, data): # to debug
global sent
print sent, …Run Code Online (Sandbox Code Playgroud)