Java Reference
In-Depth Information
private DvdResult getResultFor(DvdCommand command) throws IOException {
// this.initialize();
try {
oos.writeObject(command);
DvdResult result = (DvdResult) ois.readObject();
Exception e = result.getException();
if (! result.isException()) {
return result;
} else if (e instanceof ClassNotFoundException ) {
IOException ioe = new IOException(
"problem with demarshaling DvdCommand)");
ioe.setStackTrace(e.getStackTrace());
throw ioe;
} else if (e instanceof IOException) {
throw (IOException) e;
} else {
// well, we still have an exception, but it is up to the
// calling method to handle it
return result;
}
} catch (ClassNotFoundException cnfe) {
IOException ioe = new IOException(
"problem with demarshaling DvdResult)");
ioe.setStackTrace(cnfe.getStackTrace());
throw ioe;
// } finally {
// closeConnections();
}
}
public void finalize() throws java.io.IOException {
closeConnections();
}
/**
* A helper method which initializes a socket connection on specified port
*
* @throws UnknownHostException if the IP address of the host could not be
* determined.
* @throws IOException Thrown if the socket channel cannot be opened.
*/
private void initialize() throws UnknownHostException, IOException {
socket = new Socket(ip, port);
Search WWH ::




Custom Search