3 Replies - 160 Views - Last Post: 02 May 2013 - 05:58 PM Rate Topic: -----

#1 psh  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 65
  • Joined: 25-March 13

Peer to peer

Posted 02 May 2013 - 04:24 PM

Could you please explain me how i can achieve a peer to peer connection using sockets? :dontgetit:
Is This A Good Question/Topic? 0
  • +

Replies To: Peer to peer

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Peer to peer

Posted 02 May 2013 - 04:54 PM

One of the two, the first to be launched, has to act as a Server
and listen to a port waiting for a connection form a Client
When this is done, no reason to make difference between client/server anymore
Not really other choice
Was This Post Helpful? 1
  • +
  • -

#3 psh  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 65
  • Joined: 25-March 13

Re: Peer to peer

Posted 02 May 2013 - 05:19 PM

View Postpbl, on 02 May 2013 - 11:54 PM, said:

One of the two, the first to be launched, has to act as a Server
and listen to a port waiting for a connection form a Client
When this is done, no reason to make difference between client/server anymore
Not really other choice


What should i do if want this to work no matter which is first launched?
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: Peer to peer

Posted 02 May 2013 - 05:58 PM

Your problem is a false probelm... which is also the solution to your problem ?

Only one proces can listen to a server port

So if you can listen to that port, you are the first Server listening to it
if you can't, it means a Server is already listening, so switch yourself as a Client and connect to that port where your Server version is listening

BINGO !!!
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1