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()
评论列表
文章目录