• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Socket/sersocket - connecting to server without knowing address

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic