How to find out which ports are used by a program?
Determine PID of your program
tasklist | find "myprogram.exe"
Check ports in third column of output from
netstat /a /n /o | find " 4564"
- there is a space before PID to rule out inappropriate matches potentially coming from other columns (a little trick)
/n
keeps addresses in numeric form (without resolving) what causes the command to finish without delays (it should suffice for what you need)
If you are using windows you can use the free utility "Process Explorer" for this - among many other things. You have to run it in Administrator mode though.