Protocol
Class Peer

public class Peer
implements Runnable

Title: Peer.java

Description: This describes the interaction between the client and the peer

Copyright: Copyright (c) 2004

Company:Baylor Univ

Version:
1.0
Author:
not attributable
Constructor Detail

Peer

public Peer(torrentProcess aTorrentProcess,
            trackStruct tS)
This is the default constructor which generates the c
Parameters:
aTorrentProcess - torrentProcess
tS - trackStruct

Method Detail

toString

public String toString()
toString method which returns the peer details
Returns:
String

setChoking

public void setChoking(boolean flag)
This function sets the choking flag to true
Parameters:
flag - boolean

isBitFieldGot

public boolean isBitFieldGot()
This fumction checks if the bit field is got
Returns:
boolean

isUnchoked

public boolean isUnchoked()
This function checks if the client is unchoked
Returns:
boolean

setUnChoked

public void setUnChoked()
This function sets the client to the unchoked state

getPiecesSet

public Set getPiecesSet()
This function returns the set of pieces downloaded from this peer
Returns:
Set

downloadedPiece

public void downloadedPiece(int pieceIndex,
                            byte[] piece)
This function sets the bits for the piece and inserts the piece in the set
Parameters:
pieceIndex - int
piece - byte[]

getChokedStatus

public boolean getChokedStatus()
get the choked status of the client with this peer
Returns:
boolean

getInterestStatus

public boolean getInterestStatus()
get the interested status of the client with this peer
Returns:
boolean

setBitFieldGot

public void setBitFieldGot()
set the bit field got of the client with this peer

getSocket

public Socket getSocket()
returns the socket for this connection
Returns:
Socket

getTorrentProcess

public torrentProcess getTorrentProcess()
returns the parent torrent process
Returns:
torrentProcess

run

public void run()
Thread's run function

peerCycle

public void peerCycle()
Cycle for the client and peer to download the pieces

getReqID

public int getReqID()
This computes the requested id by interacting with the torrentprocess and checking if the one that has not been downloaded by the torrent process is downloaded by this one
Returns:
int