File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Network Application

 
Jolix Coder
Greenhorn
Posts: 2
  • 0
  • 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: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • 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
  • 0
  • 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: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic