Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to handle the Clients for Peer to Peer Connection at Server Side in Java

 
Joginder Sharma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on project which require peer to peer connection between multiple clients. Clients are Window and Android Applications. So far I am able to connect the Window and Android Application to the Server which accept the connection on two port one for Window and One for the Android. In this Project we require to send some file and other resources from window to android, when the android client request. I want to know whether it is a good practice to accept the connection from window on start-up and store the socket resources in Vector with Window Client Id, And when Android send the request for a particular window client then use that socket resource and connect window to android client, Or store the window IP and Port in Database, Create the connection to window when request came from Android. Which approach is better and how to achieve that. There may be 10L connection at the same time. I am developing all the three application(Android,Web and Window) in Java.
 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In my opinion, there are a few issues with peer to peer architectures -- and unfortunately, they are not minor issues.

First, while servers are located in a fixed location, and are generally running, this is not true for clients. The clients may be running or they may not. And the clients may be moving around. For peer to peer to work, there have to be a way to resolve the location of the client, or another client won't be able to reach it.

Second, servers are configured to be accessible by the clients. Hence, they are located to be accessible. Client can be anywhere -- including behind a firewall, or in a private network that doesn't port forward, etc. And since the client is likely moving, this can't be controlled either.

Third, servers does administrative work too. One of the items that it does is to authenticate the clients. With a peer to peer setup, the clients have to authenticate each other. This is much more difficult to do since the clients have to authenticate each other at the same time. There is no trusted starting point -- such as a server.



Anyway, IMO, if any of these are an issue, I would recommend maintaining the client / server setup. Have the server be the middle man. When a client wants to sent data to another client, it just sends it to the server with a target address -- and the server acts in the role of the messaging system.

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