larksuite-oapi/src/main/java/com/larksuite/oapi/okhttp3_14/internal/connection/RealConnection.java
private void connectSocket(int connectTimeout, int readTimeout, Call call,
      EventListener eventListener) throws IOException {
    Proxy proxy = route.proxy();
    Address address = route.address();

    rawSocket = proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.HTTP
        ? address.socketFactory().createSocket()
        : new Socket(proxy);

    eventListener.connectStart(call, route.socketAddress(), proxy);
    rawSocket.setSoTimeout(readTimeout);
    try {
      Platform.get().connectSocket(rawSocket, route.socketAddress(), connectTimeout);
    } catch (ConnectException e) {
      ConnectException ce = new ConnectException("Failed to connect to " + route.socketAddress());
      ce.initCause(e);
      throw ce;
    }

    // The following try/catch block is a pseudo hacky way to get around a crash on Android 7.0
    // More details:
    // https://github.com/square/okhttp/issues/3245
    // https://android-review.googlesource.com/#/c/271775/
    try {
      source = Okio.buffer(Okio.source(rawSocket));
      sink = Okio.buffer(Okio.sink(rawSocket));
    } catch (NullPointerException npe) {
      if (NPE_THROW_WITH_NULL.equals(npe.getMessage())) {
        throw new IOException(npe);
      }
    }
  }
/** Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket. */
Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket.
Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket .
private void connectSocket(int connectTimeout, int readTimeout, Call call,
      EventListener eventListener) throws IOException {
    Proxy proxy = route.proxy();
    Address address = route.address();
    rawSocket = proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.HTTP
        ? address.socketFactory().createSocket()
        : new Socket(proxy);
    eventListener.connectStart(call, route.socketAddress(), proxy);
    rawSocket.setSoTimeout(readTimeout);
    try {
      Platform.get().connectSocket(rawSocket, route.socketAddress(), connectTimeout);
    } catch (ConnectException e) {
      ConnectException ce = new ConnectException("Failed to connect to " + route.socketAddress());
      ce.initCause(e);
      throw ce;
    }
    try {
      source = Okio.buffer(Okio.source(rawSocket));
      sink = Okio.buffer(Okio.sink(rawSocket));
    } catch (NullPointerException npe) {
      if (NPE_THROW_WITH_NULL.equals(npe.getMessage())) {
        throw new IOException(npe);
      }
    }
  }
private void connectSocket ( int connectTimeout , int readTimeout , Call call , EventListener eventListener ) throws IOException { Proxy proxy = route . proxy ( ) ; Address address = route . address ( ) ; rawSocket = proxy . type ( ) == Proxy . Type . DIRECT || proxy . type ( ) == Proxy . Type . HTTP ? address . socketFactory ( ) . createSocket ( ) : new Socket ( proxy ) ; eventListener . connectStart ( call , route . socketAddress ( ) , proxy ) ; rawSocket . setSoTimeout ( readTimeout ) ; try { Platform . get ( ) . connectSocket ( rawSocket , route . socketAddress ( ) , connectTimeout ) ; } catch ( ConnectException e ) { ConnectException ce = new ConnectException ( "Failed to connect to " + route . socketAddress ( ) ) ; ce . initCause ( e ) ; throw ce ; } try { source = Okio . buffer ( Okio . source ( rawSocket ) ) ; sink = Okio . buffer ( Okio . sink ( rawSocket ) ) ; } catch ( NullPointerException npe ) { if ( NPE_THROW_WITH_NULL . equals ( npe . getMessage ( ) ) ) { throw new IOException ( npe ) ; } } }
Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket.
Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket .
// The following try/catch block is a pseudo hacky way to get around a crash on Android 7.0 // More details: // https://github.com/square/okhttp/issues/3245 // https://android-review.googlesource.com/#/c/271775/