Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Network Application

 
Jolix Coder
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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!
 
Henry Wong
author
Marshal
Pie
Posts: 21510
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Campbell Ritchie
Sheriff
Pie
Posts: 50263
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic