Code example for Socket

Methods: connect

0
 
    @Override public void connectSocket(Socket socket, InetSocketAddress address,
        int connectTimeout) throws IOException {
      try { 
        socket.connect(address, connectTimeout);
      } catch (SecurityException se) {
        // Before android 4.3, socket.connect could throw a SecurityException 
        // if opening a socket resulted in an EACCES error. 
        IOException ioException = new IOException("Exception in connect");
        ioException.initCause(se);
        throw ioException;
      } 
    } 
 
    @Override public void enableTlsExtensions(SSLSocket socket, String uriHost) {
      super.enableTlsExtensions(socket, uriHost);
      if (openSslSocketClass.isInstance(socket)) {
        // This is Android: use reflection on OpenSslSocketImpl. 
        try { 
          setUseSessionTickets.invoke(socket, true);
          setHostname.invoke(socket, uriHost);