code: def __send_message_recv_reply(self, packed_message):
          
          payload = io.BytesIO()
          try:
              with self._socket_lock:
                  self._socket.sendall(packed_message)
  
                  # Read first message header
                  raw_header = self._socket.recv(32)
                  header = ReplyMessage.header_from_raw_header_data(raw_header)
  
                  # from pyhdb.lib.stringlib import allhexlify
                  # print 'Raw msg header:', allhexlify(raw_header)
                  msg = 'Message header (32 bytes): sessionid: %d, packetcount: %d, length: %d, size: %d, noofsegm: %d'
                  debug(msg, *(header[:5]))
  
                  # Receive complete message payload
                  while payload.tell() < header.payload_length:
                      _payload = self._socket.recv(header.payload_length - payload.tell())
                      if not _payload:
                          break   # jump out without any warning??
                      payload.write(_payload)
  
                  debug('Read %d bytes payload from socket', payload.tell())
  
                  # Keep session id of connection up to date
                  if self.session_id != header.session_id:
                      self.session_id = header.session_id
                      self.packet_count = -1
          except socket.timeout:
              raise ConnectionTimedOutError()
          except (IOError, OSError) as error:
              raise OperationalError("Lost connection to HANA server (%r)" % error)
  
          payload.seek(0)  # set pointer position to beginning of buffer
          return ReplyMessage.unpack_reply(header, payload)
docs: Private method to send packed message and receive the reply message.
          :param packed_message: a binary string containing the entire message payload