# -*- coding=gb2312 -*- __author__ = ‘vincent‘ import socket import time import sys import locale def Client(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((‘192.168.2.100‘, 20000)) print "连接服务端" + "192.168.2.100" + ".20000" + "成功..." file_object = open(‘mpcomm.xml‘) try: all_text = file_object.read() finally: file_object.close() send_data = ‘{:0>6d}{}‘.format(len(all_text), all_text) print "发送数据:" + send_data sock.send(send_data) recv_data = sock.recv(10240) print "接受数据:" + recv_data def p(f): print ‘%s.%s(): %s‘ % (f.__module__, f.__name__, f()) if __name__ == ‘__main__‘: Client()