1
mhycy 2018-07-18 12:24:49 +08:00
代码呢?
|
2
zy820 OP @mhycy
import socketserver class MyTCPHandler(socketserver.BaseRequestHandler): def handle(self): #所有请求的交互都是在 handle 里执行的, while True: try: self.data = self.request.recv(1024).strip()#每一个请求都会实例化 MyTCPHandler(socketserver.BaseRequestHandler): print("{} wrote:".format(self.client_address[0])) print(self.data) #self.request.sendall(self.data.upper())#sendall 是重复调用 send. except ConnectionResetError as e: print("err ",e) break if __name__ == "__main__": HOST, PORT = "localhost", 9999 #windows #HOST, PORT = "0.0.0.0", 9999 #Linux server = socketserver.ThreadingTCPServer((HOST, PORT), MyTCPHandler) #线程 server.serve_forever() |
3
mhycy 2018-07-18 13:42:35 +08:00
崩掉报什么?
|
4
zy820 OP |
7
opengps 2018-07-18 14:15:56 +08:00
肯定是那些扫描之类的,发送的数据,你服务器程序识别不了,我做的 gps 接受数据也是遇到过,后来丢弃了所有不合规范的数据包之后好了
|