#!/usr/bin/env python
import socket
import sys
HOST,PORT="192.168.2.110",90
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.connect((HOST,PORT))
def recv_all(obj,msg_length):
raw_result = ''
while True:
if msg_length<=4096:
data =obj.recv(msg_length)
raw_result +=data
break
else:
data =obj.recv(4096)
raw_result+=data
msg_length-=4096
return raw_result
while True:
data =raw_input('msg to send::').strip()
if len(data) ==0:continue
sock.sendall(data+"\n")
res_size =int(sock.recv(1024))
print 'data sizefrom server',res_size
result =recv_all(sock,res_size)
print result
sock.close()