from socketserver import (TCPServer as TCP, StreamRequestHandler as SRH)
from time import ctime
HOST = ''
PORT = 1230
ADDR = (HOST, PORT)
class MyRequestHandler(SRH):
def handle(self):
print('已经连接:', self.client_address)
self.wfile.write(ctime().encode())
print(self.rfile.read().decode('utf-8'))
tcpServ = TCP(ADDR, MyRequestHandler)
print('等待新的连接。。。。')
tcpServ.serve_forever()
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |