This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes regarding peer to peer network through java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "regarding peer to peer network through java" Watch "regarding peer to peer network through java" New topic
Author

regarding peer to peer network through java

Omkar Patwardhan
Greenhorn

Joined: Feb 26, 2009
Posts: 9
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?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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

Joined: Feb 26, 2009
Posts: 9
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
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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

Joined: Feb 26, 2009
Posts: 9
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
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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

Joined: Feb 26, 2009
Posts: 9
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:




Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Omkar, please Use Code Tags. I've added them for you this time, and look how much better it looks.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

"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

Joined: Feb 26, 2009
Posts: 9
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

Joined: Feb 26, 2009
Posts: 9
"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
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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

Joined: Feb 26, 2009
Posts: 9
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
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
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

Joined: Feb 26, 2009
Posts: 9
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

Joined: Feb 26, 2009
Posts: 9
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?
 
GeeCON Prague 2014
 
subject: regarding peer to peer network through java