Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

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

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.[/B]


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 688 Times in 675 Posts

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

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Location
    Finland
    Posts
    25
    My Mood
    Bored
    Thanks
    3
    Thanked 5 Times in 5 Posts

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

    Quote Originally Posted by joginder89 View Post
    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.[/B]
    Hello and welcome.

    Im not sure if i understood you fully.

    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.
    You talk about p2p connections yet you mention server. So could you clarify your topology a bit and explain purpose of each node?

    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.
    If i got this right, you are asking if its better to store open connections in a vector and on demand use them for communication VS. having the connection parameters stored and use a new connection when needed?

    If the above is right, i'd say it depends. It depends on the frequency of the needed connections. You don't want to store idle open connections for no good reason, plus you'd have to remember to close em. But if you need the connections frequently ( opening new connection cost > payload ) then it makes sense to store them somewhere.

    Somewhere in the middle would be to store the connections and have a timeout on them and on each request check if there is already an open connection, if not, then create a new one.

    There may be 10L connection at the same time.
    What you mean by 10L ? 10 ?

    Thats my 2 cents at least Sorry for the shoddy answer, maybe ill be able to give an stronger opinion after getting some more info

  4. #4
    Junior Member
    Join Date
    Dec 2017
    Location
    United States
    Posts
    5
    Thanks
    0
    Thanked 4 Times in 1 Post

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

    Found a relevant ques to yours on stack overflow. have a look at this - https://stackoverflow.com/questions/...client-sockets
    A B.Tech IT Graduate, an avid reader who loves to travel to beautiful places, and cooks in free time.
    Read my Blog - What is Wireless LAN

  5. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

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

    The person asked the question and then departed. Three years ago.

    Please don't resurrect old posts. Although self advertising with links might be ok in the "Paid Java Projects", making a nuisance of itself in technical forums can only make your site look bad.

Similar Threads

  1. Getting the peer address for a socket
    By daved in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 26th, 2013, 03:44 PM
  2. Peer to Peer chat program
    By keepStriving in forum Java Networking
    Replies: 0
    Last Post: June 17th, 2013, 07:17 PM
  3. How to detect if Socket is closed by remote peer?
    By anis_huq in forum Java Networking
    Replies: 1
    Last Post: July 13th, 2012, 09:36 AM
  4. Server/clients connection periodically ask for a file
    By akis3110 in forum Java Theory & Questions
    Replies: 2
    Last Post: June 28th, 2011, 08:06 AM
  5. Java nio socket for peer to peer model
    By perl0101 in forum Java Networking
    Replies: 3
    Last Post: April 5th, 2011, 09:41 AM

Tags for this Thread