public void init(ChatServer server,String args[]){
		this.server=server;
		ExpirationChecker expirationChecker=new ExpirationChecker(server);
		expirationChecker.start();
		int serverPort;	
	    
		try{
			serverPort = Integer.parseInt(args[0]);
		}catch(Exception e){
			serverPort=8000;
		}
		
		Runtime.getRuntime().addShutdownHook(new Thread() {
			public void run() {
				System.out.println("Cleanning up resources and shutting down server:");
				System.out.println("Closing connections ...");
				for(Connection con:connections){
					try{
						if(con.in!=null) con.in.close();
						if(con.out!=null)con.out.close();
						if(con.cipherIn!=null)con.cipherIn.close();
						if(con.cipherOut!=null)con.cipherOut.close();
					}
					catch(IOException e){}
				}
				System.out.println("Serializing private table...");
				serializeTable();
				System.out.println("Encrypting private table...");
				encryptSerializedTable();
			}
		});
		
		
		try {
			System.out.println("Starting server...");
			System.out.println("Decrypting private table...");
			decryptSerializedTable();
			System.out.println("Unserializing private table into memory...");
			unserializeTable();
			
			ServerSocket serverSocket = new ServerSocket(serverPort);
			System.out.println("Listening on port "+serverPort+"...");
			
			while(true) {
				Socket clientSocket = serverSocket.accept();//listen for new connections
				System.out.println("New client: "+clientSocket);
				ObjectOutputStream outputStream=new ObjectOutputStream(clientSocket.getOutputStream());
				outputStream.flush();
				ObjectInputStream inputStream=new ObjectInputStream(clientSocket.getInputStream());

				Connection connection=new Connection(this,clientSocket,inputStream,outputStream);
				synchronized(this){
					connections.add(connection);
				}
				connection.start();
            }
			
		} catch (IOException e) {
			System.out.println("An error has ocurred: "+e.getMessage());
		}
		
		
	}