#NEWLINE# def sendmsg( self , filename , msg ) : #NEWLINE# #INDENT# global logger #NEWLINE# logger . log ( 'INFO' , 'TCPclient_sendmsg' , ( ( filename + ', ' ) + msg ) ) #NEWLINE# psize = 16 #NEWLINE# bufsize = 1048576 #NEWLINE# size = 1024 #NEWLINE# ip = '127.0.0.1' #NEWLINE# try : #NEWLINE# #INDENT# s = self . init ( ip ) #NEWLINE# s . send ( bytes ( ( ( filename + '#' ) + msg ) , 'utf8' ) ) #NEWLINE# ret = s . recv ( psize ) #NEWLINE# qsize = int ( ret . decode ( 'utf8' ) . strip ( '\x00' ) ) #NEWLINE# s . send ( bytes ( '1' , 'utf8' ) ) #NEWLINE# temp = b'' #NEWLINE# rect = 0 #NEWLINE# while ( rect < qsize ) : #NEWLINE# #INDENT# if ( ( qsize - rect ) > qsize ) : #NEWLINE# #INDENT# data = s . recv ( bufsize ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = s . recv ( ( qsize - rect ) ) #NEWLINE# #UNINDENT# rect = ( rect + len ( data ) ) #NEWLINE# temp = ( temp + data ) #NEWLINE# #UNINDENT# ret = pickle . loads ( temp ) #NEWLINE# #UNINDENT# except socket . error as msg : #NEWLINE# #INDENT# logger . log ( 'ERROR' , 'TCPclient_sendmsg' , ( 'Socket Exception: ' + str ( msg ) ) ) #NEWLINE# ret = Packet ( '' , '' , None , None , 1 , None , None ) #NEWLINE# #UNINDENT# except Exception as msg : #NEWLINE# #INDENT# logger . log ( 'ERROR' , 'TCPclient_sendmsg' , ( 'Otehr Exception: ' + str ( msg ) ) ) #NEWLINE# ret = Packet ( '' , '' , None , None , 1 , None , None ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# s . close ( ) #NEWLINE# return ret