#NEWLINE# def recv( self ) : #NEWLINE# #INDENT# 'Receive message from socket.\n\n        Returns:\n            The message sent from client.\n        ' #NEWLINE# chunks = [ ] #NEWLINE# bytes_recvd = 0 #NEWLINE# while ( bytes_recvd < PREFIX_LEN ) : #NEWLINE# #INDENT# chunk = self . s . recv ( min ( ( PREFIX_LEN - bytes_recvd ) , PREFIX_LEN ) ) #NEWLINE# if ( not chunk ) : #NEWLINE# #INDENT# raise socket . error ( 'socket connection broken' ) #NEWLINE# #UNINDENT# chunks . append ( chunk ) #NEWLINE# bytes_recvd += len ( chunk ) #NEWLINE# #UNINDENT# header = '' . join ( chunks ) #NEWLINE# msglen = struct . unpack ( '>I' , header ) [ 0 ] #NEWLINE# del chunks [ : ] #NEWLINE# bytes_recvd = 0 #NEWLINE# while ( bytes_recvd < msglen ) : #NEWLINE# #INDENT# chunk = self . s . recv ( min ( ( ( msglen - bytes_recvd ) , SIZE ) ) ) #NEWLINE# if ( not chunk ) : #NEWLINE# #INDENT# raise socket . error ( 'socket connection broken' ) #NEWLINE# #UNINDENT# chunks . append ( msglen ) #NEWLINE# bytes_recvd += len ( chunk ) #NEWLINE# #UNINDENT# return base64 . b64decode ( '' . join ( chunks ) )