client.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:challenges 作者: dwyde 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号