How does a client find the port number of a server?

Posted by Jonathan on Stack Overflow See other posts from Stack Overflow or by Jonathan
Published on 2010-04-01T05:43:48Z Indexed on 2010/04/01 5:53 UTC
Read the original article Hit count: 267

Filed under:
|

Hello all,

I am currently learning about basic networking in java. I have been playing around with the server and client relationship between two of my computers. However, I cannot figure out how distributed programs (say, a videogame), can not only find the 'host' computer, but also the port number on which the server is running in order to create a Socket between the two computers. The only way I really see to create a Socket is with an already known IP Address, and with a known port number.

How do you search a LAN network for another computer (host) searching for clients?

How do you determine what port the server is located on without 'pinging' all available ports for a response (which, I understand, is bad form... Something about 'server attack'...)?

In such a situation as a video game, there can be any number of computers on the same network, and any number of them might be attempting to host, or otherwise running the application. Any other important information, or perhaps reference to a more detailed tutorial than the one I am using, regarding making connections on so very little information on the client side would be appreciated.

Many thanks,

Jonathan

© Stack Overflow or respective owner

Related posts about java

Related posts about client-server