client.py 文件源码

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

项目:LMDocker-project 作者: xiaozhazi 项目源码 文件源码
def send_file():

    try:
        socket.connect((HOST,PORT))
    except Exception,e:
        print 'Error connecting to server:%s'% e

    full_name = '/tmp/' + image_name + '.tar'

    print 'send:' + full_name

    try:
        socket.send(full_name,1024)
        data = socket.recv(1024)
    except Exception,e:
        print 'Error,socket send and recv file name failed:%s' % e
        return

    if data == 'ready':
        file_to_send = open(full_name,'rb')
        while True:
            data = file_to_send.read(4096)
            if not data:
                break;

            socket.sendall(data)

    file_to_send.close()
    socket.send('',1024)
    socket.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号