/** * Create, configure and connect a socket. * @param address The address to connect to * @param options The socket options to configure. If null, no socket options will be configured * @return The configured and connected socket * @throws IOException */ public static Socket createAndConnect(SocketAddress address, SocketOptionsConfig options) throws IOException { final Socket result = new Socket(); configureSocketOptions(result, options); logger.debug("Connecting socket"); if (options != null && options.hasConnectTimeout()) { result.connect(address, options.getConnectTimeout()); } else { result.connect(address); } logger.debug("Socket connected"); return result; }
/** * Create, configure and connect a socket. * @param address The address to connect to * @param options The socket options to configure. If null, no socket options will be configured * @return The configured and connected socket * @throws IOException */ public static Socket createAndConnect(SocketAddress address, SocketOptionsConfig options) throws IOException { final Socket result = new Socket(); configureSocketOptions(result, options); logger.debug("Connecting socket"); if (options != null && options.hasConnectTimeout()) { result.connect(address, options.getConnectTimeout()); } else { result.connect(address); } logger.debug("Socket connected"); return result; }