Java Reference
In-Depth Information
L ISTING 6.6 Continued
private String thisClientId;
/**
* Class constructor
*
*/
public BankClientManager() {
try {
socket = new Socket(“localhost”, 3333);
out = new DataOutputStream(socket.getOutputStream());
in = new DataInputStream(socket.getInputStream());
} catch (Exception e) {
System.out.println(“BankClientManager()- Couldn't work out the
connection: “+e);
System.exit(1);
}
System.out.println(“BankClientManager() - Connectiom established.”);
}
/**
* implements the POST Command
*/
public void post(String data) throws IOException{
sendCommand('p');
out.writeUTF(data);
}
/**
* implements the QUIT Command
*/
public void quit() throws IOException{
sendCommand('q');
out.close();
in.close();
socket.close();
}
/**
* implements the GET Command
*/
public byte[] get(String serverFilename) throws IOException{
sendCommand('g');
out.writeUTF(serverFilename);
int size = in.readInt();
byte[] b = new byte[size];
in.readFully(b);
Search WWH ::




Custom Search