Results 1 to 4 of 4
  1. #1
    tambeo91 is offline Member
    Join Date
    Aug 2011
    Rep Power

    Default TCP Socket to build a program like torrent

    Hi all.
    I have a project in my network subject.
    i have to build a program like torrent. but i dont't know how the torrent work with its file.i only know in torrent i can download a file from other computers but when i design, i have no idea about how i can get one part of file in one computer and another part in another computer.
    can you show me some idea or document.
    thanks all

  2. #2
    LG87 is offline Member
    Join Date
    Jun 2011
    Rep Power

    Default Re: TCP Socket to build a program like torrent

    Well, a torrent program works somewhat like a request'er.
    When you start the program, it contacts the tracker which gives out IP's, ports etc of
    others downloading/uploading the same file..

    The torrent program then tries to connect to many of them on the selected ports,
    and basically starts sending out requests to the other torrent clients for which parts of the files
    that you don't have.
    So in the .torrent file that you design (or whatever type you name it), you can specify the size of
    each chunk. Lets say one chunk is 512 kb (a lot less in a torrent program last time i checked but not sure).
    So since you know the size of the origianl size (says so in your ".torrent" file), then you can request
    from others lets say: chunk nr 12 (which is then 12*512 = 6144 kb start, and ends at 6144 + 512).
    But for all the logic on how to send (since some clients / leechers / seeders) you dont get anything from,
    so at times you will have to request same file / chunk from multiple users etc..

    This is just a quick wrapup on how it works and how u can make it, I'm not an expert at torrent programs but
    got a general understanding. Sorry if something is wrong, but it should work somewhat like mentioned

  3. #3
    Grkn is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default Re: TCP Socket to build a program like torrent

    I made something similar before in network project.

    There are important cases.

    1- You have to design peer to peer application (Torrent's real structure)
    //Most probably you teacher wants peer to peer application so he/she gives torrent.
    if you don't know peer to peer, then I will explain briefly.
    You will create a network in (local lan) or (internet).
    Ex: When a computer(source) sends message to other computer(dest), that message will travel in other computers untill it arrives destination computer.
    Don't forget to create own network. Message will travel on your network.
    Also there are some cases to causes deadLock(network collapses) so prevent those situations.
    When I mentioned about your network, there can be some restirictions as well such as 1 computer can only connect 1 computer -or- 1 computer can only connect 2 computer.....

    2- Don't forget that when you are searching a file that will be downloaded, you can find that in other computers as well.
    Download will be in chuncks. Each chunck size changes according to coder. (256K,128K,512K,32K) //I recommend you 256K
    Ex: Your File is 5 mb. You found that file in two computers.
    So every file has chunks that means You want to download chunck1 to computer(A) , chunk2 to computer(B) untill all chuncks are downloaded.
    //Last recommend: Just search for CRC. java has some CRCs such as CRC32...

    I wont explain the CRC :) it will get bigger and bigger

  4. #4
    Grkn is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default Re: TCP Socket to build a program like torrent

    First send Message that I am searching for a file named as ("HELLO.jpg");
    Wait some time untill a message returns from computers.
    IF it does not return, then file can not be found
    Send computers a message that ("GIVE ME CHUNCK NUMBERS & CRC VALUES OF THAT FILE")

    Each computer on your network sends those chunk numbers & chunk CRC values.
    Just keep those informations in your computer. Chunk information & Computer IDs
    //But there are some cases as well. What if someone changes file name to "HELLO.jpg" that means it is completely usesless
    //CRC can be used in that case. CRC values are calculated according to bits with special bitwise algorithm (Computing takes long time so keep log about CRC values in source folder for each file)
    Just write a algorithm that detects which chuncks are real(HELLO.jpg)
    Then you have real computer IDs and chunck informations. Don't try to download all chunks at the same time. Each computer must send one chunk at a time.
    Untill last chuck is downloaded keep downloading.

    //Downloading can be done in two cases
    1- Download the chunck from source computer with direct connection
    2- Download th chunck from source computer with network

    Second way is better but complicated than first one.

Similar Threads

  1. JAVA Socket Program
    By kappilrinesh in forum New To Java
    Replies: 3
    Last Post: 10-02-2011, 06:45 PM
  2. how can I build a telephone program
    By m-i-l-s-o-n in forum New To Java
    Replies: 1
    Last Post: 09-22-2010, 03:31 AM
  3. Encode data to torrent?
    By greatmajestics in forum AWT / Swing
    Replies: 0
    Last Post: 04-28-2010, 05:12 PM
  4. Torrent Episode Downloader 0.90
    By levent in forum Java Software
    Replies: 0
    Last Post: 08-02-2007, 06:56 PM
  5. Torrent Episode Downloader 0.80
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-01-2007, 07:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts