• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Network Application

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I'm making a simple application that should communicate with each other over the internet.
When starting the app, you are asked to be the client or the server. (I allow only 1 client and 1 server)
I know how to work with sockets and I am going to use the "knock knock" protocol.

My question is: how do I know the hostadress of the server when the server could be running on any random PC over the internet.
Thanks in advance!
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jolix Coder wrote:
My question is: how do I know the hostadress of the server when the server could be running on any random PC over the internet.



Simply. You can't. With client/server, the client needs to know how to get to the server -- the server location has to be reachable and can't be random.

If your applications need to find each other, then you have the logic for both sides to go to an agreed upon location to resolve each others' location. It could be at a multicast group and port, which will require that switches route those packets, or it could be at another address and port, which will require some sort of service to resolve the addresses. Even peer to peer environments uses starting locations, to find peers to other peers to eventually, a peer that has what you want.

Henry
 
Jolix Coder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for your answer!

Henry Wong wrote:..., which will require some sort of service to resolve the addresses.


Is there some kind of free service out there that just does that?
I have no idea what to google :p
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want this to work over the internet? Then you should be aware that multicast doesn't work on a network of that size. (You don't want people sending multicasts to millions of hosts, that's just going to plug up the network, so it isn't allowed.) So if your plan requires a network of servers, which can't easily be located, you're going to have to provide that service yourself. Your website would be an ideal place to host that service.

You might also want to investigate how other p2p applications do that.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic