发布时间:2019-09-26 07:24:46编辑:auto阅读(2161)
#修改代码
from socket import *
from time import ctime
HOST = 'localhost'
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST,PORT)
tcpSocket = socket(AF_INET,SOCK_STREAM) #创建套接字
tcpSocket.bind(ADDR) #绑定地址
tcpSocket.listen(5) #设置监听上限
while True:
print('waiting for connect...')
tcpClient,addr = tcpSocket.accept()
print('...connect from addr:',addr)
while True:
data = tcpClient.recv(BUFSIZ).decode()
if not data:
break
tcpClient.send(('service'+ctime()+'--'+data).encode())
tcpClient.close()
tcpSocket.close()上面程序中,如下红色标注是有关编码和解码修改的代码:
while True:
data = tcpClient.recv(BUFSIZ).decode()
上一篇: Centos7上安装Python3
下一篇: 基于Python3的漏洞检测工具 ( P
51146
50551
41171
38005
32468
29372
28237
23088
23053
21375
1424°
2124°
1764°
1688°
1985°
1763°
2439°
4103°
3980°
2841°