@Override
	public void run() {
		
		Socket sock;
		
		while(running){//tcp listener main loop
			try {
				sock = servSock.accept();
				System.out.println("client has connected");
				
				addClientToList(sock);
				
			} catch (Exception e) {
				if(!(e instanceof InterruptedException)){
					e.printStackTrace();
				}
			}
		}
		
		System.out.println("TcpListener exit");
		
		for(int i=0;i<clients.length;i++){//close all connections
			try {
				clients[i].close();
			} catch(Exception e){}
		}
		
		try { //close the server
			servSock.close();
		}catch(Exception e){}
	}