out.write(("CONNECT " + path + " HTTP/1.0\n\n").getBytes(CharEncoding.UTF_8));
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String response = reader.readLine();
if (!CONNECTED.equals(response)) {
s.close();
throw new GoRpcException("unexpected response for handshake " + response);
}
return new Client(cFactory.createCodec(s));
} catch (IOException e) {
if (s != null) {
try {
s.close();
} catch (IOException e1) {
logger.error("unable to close socket", e1);
throw new GoRpcException("unable to close socket" + e1.getMessage());
}
}
logger.error("connection exception", e);
throw new GoRpcException("connection exception " + e.getMessage());
}
}