docs: def recv(conn, size):
      """
      Receive bytes from connection socket or stream.
  
      If size is struct.calcsize()-compatible format, use it to unpack the data.
      Otherwise, return the plain blob as bytes.
      """
      try:
          fmt = size
          size = struct.calcsize(fmt)
      except TypeError:
          fmt = None
      try:
          _read = conn.recv
      except AttributeError:
          _read = conn.read
  
      res = io.BytesIO()
      while size > 0:
          buf = _read(size)
          if not buf:
              raise EOFError
          size = size - len(buf)
          res.write(buf)
      res = res.getvalue()
      if fmt:
          return struct.unpack(fmt, res)
      else:
          return res