python - sockets block on send for some reason -


trying implement compressed communication on raw sockets using socketserver. handler class read

        raw_message = []        while true:            data = self.request.recv(1024)            if not data:                break            raw_message.append(data)        raw_message = ''.join(raw_message) 

and tries decompress , send me reply. client code goes this

     try:         sock.connect(('myhost', 8075))     except exception e:         print('failed connect', e)     compressed = zlib.compress(bytes(payload, 'utf-8'))     print('payload length: ', len(payload))     print('compressed length: ', len(compressed))     try:         sock.sendall(compressed)      except exception e:         print('failed send', e)     print('sent')     data = sock.recv(4096)     print('data: ', zlib.decompress(data)) 

somehow server never gets out of "while true:" loop though every tutorial says should work way. doing wrong?

edit: looks continuous communication on single socket requires bit of planning, both ends know when communication starts , stops. expected handled send() , recv() apparently not.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -