title: What port number shall I use?
body: <p>I am writing an app that is to be running on a Windows PC. I need to create a server socket listening on 127.0.0.1, and another client socket which is to connect with this server socket.</p>
  <p>Since the data exchange between the two sockets are <strong>within the same machine</strong> and there is no client connecting from outside of the machine, what port to use is insignificant, as long as the two sockets use the same port number.</p>
  <p>So, <strong>how do I decide which port number to use</strong>? Shall it be a hard-coded port number such as 49500? What if another unrelated app on this machine happen to use this port number? Or shall I get the list of all used ports and <strong>programmatically</strong> pick an unused port?</p>
  <p>Just want to know what is the best approach. Thanks.</p>