/** * Connect via a proxy. * * @throws SocketException * @throws IOException */ private void connectViaProxy() throws NetworkException, SocketException, IOException { socket = newSocket(); if (Boolean.FALSE == protocol.isSecure()) { /* secure sockets must already be connected */ socket.connect(networkImpl.lookupSocketAddress(address), getConnectTimeout()); } }
/** * Create a new socket. * * @return A <code>Socket</code>. */ private Socket newSocket() throws NetworkException, UnknownHostException { if (protocol.isSecure()) { return networkImpl.newSecureSocket(id, proxy, address); } else { return networkImpl.newSocket(id, proxy); } }
/** @see com.thinkparity.network.NetworkConnection#disconnect() */ @Override public void disconnect() { logger.logTraceId(); logger.logInfo("{0} - Disconnect", getId()); if (isConnected()) { try { if (Boolean.FALSE == protocol.isSecure()) { socket.shutdownInput(); } } catch (final IOException iox) { logger.logWarning(iox, "{0} - Error disconnecting.", getId()); } finally { try { if (Boolean.FALSE == protocol.isSecure()) { socket.shutdownOutput(); } } catch (final IOException iox) { logger.logWarning(iox, "{0} - Error disconnecting.", getId()); } finally { try { socket.close(); } catch (final IOException iox) { logger.logWarning(iox, "{0} - Error disconnecting.", getId()); } finally { socket = null; input = null; output = null; logger.logInfo("{0} - Disconnected", getId()); connected = false; } } } } else { logger.logWarning("{0} - Is not connected.", getId()); } }