Java Reference
In-Depth Information
L ISTING 6.4 Continued
* saves properties files
*/
private void saveProperties(){
try {
FileOutputStream out = new FileOutputStream(SERVER_DIR+PROPS_FILE_NAME);
downloadPolicy.store(out, “—-Bank Server download Policies file—-”);
out.close();
}
catch (IOException ex) {
System.out.println( header + “saveProperties(): “+ex);
}
System.out.println( header + “save” );
}
/**
* It launches the server
*/
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(3333);
} catch (IOException e) {
System.out.println(“BankServer - Could not listen on port: 3333: “+e);
System.exit(-1);
}
System.out.println(“BankServer - Waiting for Connections.”);
boolean listen = true;
while(listen) {
// connection started
Thread t = new Thread(new BankServer(serverSocket.accept()));
t.start();
}
serverSocket.close();
}
}
The server uses a properties file to handle the CHECK command from clients. In this text file
are stored the list of files that must be installed in the client cache. A simple example of such a
file is shown in Listing 6.5.
Search WWH ::




Custom Search