Low-effort take: can't you just run ss -tulpn repeatedly and parse the output?