How to programmatically query the forwarding port is a NAT?
There is an application server that is behind a NAT (perhaps even several), you need to accept connections from the Internet.
Google brought upon NAT-PMP Protocol and the RFC 6886
But the specifications are not very understand how to form the query, and so it is not clear whether you can request any free port or have to pick them up to succeed.
Maybe someone will throw up more references to human readable manuals in Russian/English?