If port 0 is supplied, the Linux kernel will select an available port. Reference: https://github.com/torvalds/linux/blob/2c271fe77d52a0555161926c232cd5bc07178b39/net/ipv4/inet_connection_sock.c#L358
This is also true for Windows: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-bind#remarks
Since this behavior does not appear in manpages for bind(), listen(), etc. it is not reasonable to expect node operators to know this behavior exists, so it’s best to document it where they will find it: in the help text.