This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket/sersocket - connecting to server without knowing address

 
Chris Blanchard
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

At the moment I'm using ServerSocket to host a game on a certain port, and any clients need to know the local address of the server or it's IP to be able to connect.

What I'd like to be able to do is let the client have a quick connect option where it searches for a server on the network and is able to connect for one without knowing the servers address.

Is there a way of doing this or any tutorials I can have a look at?

Thanks
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that like sending a letter through snail main to friend without knowing their address?

If the server and all clients are on the same LAN it might be possible to rig something up using broadcast, scanning all active ports(if you don't know the port number) on all machines in the LAN, but it could hardly be called a quick connect. If they are not all part of the same LAN, forget about it.

If, for whatever reason the IP address of the server might be different each time, run a small server program on a machine with a static IP whose only purpose in life is to accept the address from the server and then sending that to clients.
 
Darrin Cartwright
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,

You could always define a "Master" server with a known IP address (or domain name). Each instance of the "Server" would just need to register it's IP with the "Master" to notify everyone that it is accepting clients. The clients could connect to this Master server and receive a list of other servers IP addresses. The client could then ping each IP in turn to determine if the server exists, and then attempt a connection.
Just a thought!

Darrin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!