• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding peer to peer network through java

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Boss,
give me a guideline how to have a peer to peer network through java?
i have so far written client and server programs.
i can generate a list of all the peers in the network.
i can search for all the files in all the drives of all the peers for a particular file extension.
but am unable to read files once they are sent from url to the peer where they are desired.
also am facing the difficulty of stop and resume.
i wanted to simulate bittorrent but at least i want to have some functionality of it.
well i have tried having an array and storing bytes in it. and adding bytes from where we left for stop and resume.
but it is problematic for video files. also if you stop something and shutdown the node that file download is lost and we cannnot resume it once we start our node again.
do you have some idea as to how to progress?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A google search for "java peer to peer" will reveal that other people have tackled this problem.

Sun's preferred solution is JXTA but you can find plenty of others.

Bill
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:A google search for "java peer to peer" will reveal that other people have tackled this problem.

Sun's preferred solution is JXTA but you can find plenty of others.

Bill



I have gone through jxta technology. but i want to implement this within a lan as jxta as i understand works solely on internet.that is why i am facing the problem.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A google search for "java jxta lan" reveals that a number of people have asked about JXTA on a Lan and gotten suggestions.

Bill
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:A google search for "java jxta lan" reveals that a number of people have asked about JXTA on a Lan and gotten suggestions.

Bill



Thanks. I got plenty of examples and codes. But i am confused as to whether half of the implementation i have done on java j2se and whether the remaining can be done on jxta.
I have written simple or rather lengthy java programs to find peers on the network , to search for files on the peers, to break the files into pieces and send them to other peers.
if i want to do the remaining codes in jxta as i understand i would have to import net.java.jxta package but can it be done? like ocmbing simple java with jxta?
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you have already written functions for much of what JXTA does so I suspect you would have to make major changes in your existing code to use JXTA. Perhaps it will be easier to continue with your current architecture and you will certainly learn a LOT about distributed systems.

What do you have running now when one of your peers has discovered that another peer has a desired file?

Bill

 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:It sounds like you have already written functions for much of what JXTA does so I suspect you would have to make major changes in your existing code to use JXTA. Perhaps it will be easier to continue with your current architecture and you will certainly learn a LOT about distributed systems.


do you mean that now as i have written java codes for having a graphical user interphace , java code to find peers in network and java code to break file into pieces and send it over network , then i cannot do implementation of security in p2p network by using jxta? cannot i implement groups as in jxta by importing the packagaes and using claasses and methods of jxta?

William Brogden wrote:
What do you have running now when one of your peers has discovered that another peer has a desired file?

Bill



The code to find peers over network is as follows:

Herein the package ListComp we have written codes to search directory and files.

The code to search file is:


The code to split file which i got thanks to coderanch:


The code to read file over a network:




 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Omkar, please Use Code Tags. I've added them for you this time, and look how much better it looks.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"stupid coder", please check your private messages regarding an important administrative matter.

Thank you.

And in among all that code, I couldn't find your actual question. Could you tell us again what it is?
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:
And in among all that code, I couldn't find your actual question. Could you tell us again what it is?


Well
1. I want to deelop a peer to peer network in java language over a lan without having to use jxta. have done some things which are actually very few in java and now want to do other security and making groups of peers through jxta. is it possible?

2. can anyone give me any idea as to how upload takes place in a peer to peer network? that i show do we code it in java?
i have the idea to send file block by block and keep the sequence number of the blocks sent in stack and resume from where we left off once user clicks on pause in gui. also how do we ensure pause, stop and resume will work when we shut down the node and trun it back up again?

3.one more problem i face is how to maintain the exact file extension as i pass the file over network.
now as i have broken file in pieces i can rearrange a text file that is regenerate it at other node. but i can break a .mp3 or .xls file but regeneration is problem.
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"stupid coder", please check your private messages regarding an important administrative matter.

Thank you.

Paul Clapham wrote:
And in among all that code, I couldn't find your actual question. Could you tell us again what it is?



ALSO IS IT POSSIBLE IN ANY WAY TO DO THE FOLLOWING:
LET US TAKE THE SCENARIO OF THREE COMPUTERS A B AND C.
A downloads a certain file test.txt from node B. C wants the same file and sends request to node B. But instead of node B uploading the file to node C , node A sends whatever blocks of file it has received to node C thus reducing the load on node B. And this needs to work on any random pair or group of nodes.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think it will be possible for you to mix what you showed us with JXTA - if you really want all those capabilities, such as security and being able to resume transfers, it is time to discard your first draft and try again.

If you want to continue with the existing code, you better review it for consistent treatment of byte streams as bytes, I see at least one place where you are creating a Reader - that will always attempt to interpret bytes as 16 bit characters in some character set.

Bill
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think it will be possible for you to mix what you showed us with JXTA - if you really want all those capabilities, such as security and being able to resume transfers, it is time to discard your first draft and try again.

William Brogden wrote:If you want to continue with the existing code, you better review it for consistent treatment of byte streams as bytes, I see at least one place where you are creating a Reader - that will always attempt to interpret bytes as 16 bit characters in some character set.

Bill


could you be more specific as to where i should treat bytes consistently?
i am trying to download or rather transfer file using nio form one pc to other.
is it a feasible way to do so?
what should be the criteria for differentiation if i am to make groups of peers and allow facility for a peer to join or come out of any group?
like i want to spearate out those computers which are used by faculty or professors and those by students.
also i want to allow student nodes to have groups in nay way they wish.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

could you be more specific as to where i should treat bytes consistently?



Search your code for uses of classes which contain "Reader" or "Writer" in the class name. Study the JavaDocs for the java.io package, paying attention to the distinction between byte stream processing - as in InputStream and character stream processing as in Reader.

Bill
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That i have somewhat handled.
but am clueless as to how to differentiate the computers.
i want to give all the clients or the nodes where a software gets installed the facility to make groups and addd nodes or join already existing groups. how to do it?
 
Omkar Patwardhan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That i have somewhat handled.
but am clueless as to how to differentiate the computers.

Omkar Patwardhan wrote:i want to give all the clients or the nodes where a software gets installed the facility to make groups and addd nodes or join already existing groups. how to do it?


does anyone have nay idea how to do it?
 
reply
    Bookmark Topic Watch Topic
  • New Topic