public PeerManager(int portNumber, Tracker tracker, String flag){
		port = portNumber;
		this.tracker = tracker;
		this.flag = flag;
		downloading = false;
		peerList = new ArrayList<Peer>(MAX_PEERS);
		th = this.tracker.getTorrentHandler();
		th.setPeerManager(this);
		
		if(flag.equals("")){
			peerCheck = new Thread(new PeerListener());
			peerCheck.start();
			
			try {
					server = new ServerSocket(port);
					serverCheck = new Thread(new ServerListener());
					serverCheck.start();
				} catch (IOException e) {
					System.err.println("PeerManager's server has run into an issue and failed to initilize");
				}
			
			//peerPulse checks if a peer is still active (see documentation
					peerPulse = new Thread(new PeerPulse());
					peerPulse.start();
					
			//this thread is used to check to see which threads are choked and which are un choked. it runs every 30 minutes.
					
					chokeCheckThread= new Thread(new ChokeCheck());
					chokeCheckThread.start();
					
				
			
		}
		//They did input a flag
		else{
			Socket s;
			try {
				s = new Socket(flag, port);
			
				Peer p = new Peer(s, th, tracker.getPeerId());
					if(p.connect()){
						add(p);
						System.out.println("Downloading Connection from: " + p.ip);
						p.download();
						
					}	
				} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				System.err.println("There was a bad flag input. You should Exit");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				System.err.println("There was a bad flag input. You should Exit");
			}
		}
	}