def communicate(host, port):
""" Read from stdin till EOF, send, then return the results of recv().
"""
s = socket.socket()
s.connect((host, port))
payload = sys.stdin.read().encode()
s.sendall(payload)
s.shutdown(socket.SHUT_WR)
output = []
while True:
read = s.recv(READ_SIZE)
if read:
output.append(read.decode())
else:
break
return ''.join(output)
评论列表
文章目录