To find out the network ports currently opened by running software on a Linux machine, simply use LSOF (list open files). This can also sort out the communication port as well.
To display IPv4 ports :
lsof -Pnl +M -i4
To display IPv6 ports :
lsof -Pnl +M -i6