I'm in a situation where I would like to have a ServerSocket that listens on a specific port. However, if this port is already taken, I would like to listen on a different port. How can I advertise what port my Java program is listening on, so that clients who are connecting to my machine know what port to connect to? Otherwise I do not see how a client would know where to connect to. If anyone has any useful links, advice, or even search terms that would be helpful, as I don't see anything. Thanks.