public Socket connect() throws IOException, ConfigurationException {
  if (useSSL) {
    sslFactory=SSLSocketFactory.getDefault();
    SSLSocket sslSocket=(SSLSocket)sslFactory.createSocket();
    SecurityHelper.setCiphersAndProtocolsToSSLSocket(sslSocket,SecurityHelper.getCiphers(),SecurityHelper.getProtocols());
    socket=sslSocket;
  }
 else {
    SocketChannel channel=SocketChannel.open();
    socket=channel.socket();
  }
  setSocket(socket);
  try {
    socket.connect(address,connectTimeout);
  }
 catch (  IOException e) {
    if (done) {
      throw new SocketTerminationException("Socket has been terminated",e);
    }
 else {
      throw e;
    }
  }
  socket.setTcpNoDelay(true);
  socket.setKeepAlive(true);
  socket.setSoTimeout(readTimeout);
  return socket;
}

public Socket connect ( ) throws IOException , ConfigurationException { if ( useSSL ) { sslFactory = SSLSocketFactory . getDefault ( ) ; SSLSocket sslSocket = ( SSLSocket ) sslFactory . createSocket ( ) ; SecurityHelper . setCiphersAndProtocolsToSSLSocket ( sslSocket , SecurityHelper . getCiphers ( ) , SecurityHelper . getProtocols ( ) ) ; socket = sslSocket ; } else { SocketChannel channel = SocketChannel . open ( ) ; socket = channel . socket ( ) ; } setSocket ( socket ) ; try { socket . connect ( address , connectTimeout ) ; } catch ( IOException e ) { if ( done ) { throw new SocketTerminationException ( "Socket has been terminated" , e ) ; } else { throw e ; } } socket . setTcpNoDelay ( true ) ; socket . setKeepAlive ( true ) ; socket . setSoTimeout ( readTimeout ) ; return socket ; }
connect to the server .
