docs: def recvline(sock):
      """Receive a single line from the socket."""
      reply = io.BytesIO()
  
      while True:
          c = sock.recv(1)
          if not c:
              return None  # socket is closed
  
          if c == b'\n':
              break
          reply.write(c)
  
      result = reply.getvalue()
      log.debug('-> %r', result)
      return result