正在查看: Kreate v1.5.0 应用的 SocketImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Kreate v1.5.0 应用的 SocketImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.ktor.network.sockets;
import io.ktor.network.selector.SelectInterest;
import io.ktor.network.selector.SelectorManager;
import io.ktor.network.sockets.SocketOptions;
import java.net.InetAddress;
import java.nio.channels.SocketChannel;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
@Metadata(d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0000\u0018\u0000*\n\b\u0000\u0010\u0002 \u0001*\u00020\u00012\b\u0012\u0004\u0012\u00028\u00000\u00032\u00020\u0004B#\u0012\u0006\u0010\u0005\u001a\u00028\u0000\u0012\u0006\u0010\u0007\u001a\u00020\u0006\u0012\n\b\u0002\u0010\t\u001a\u0004\u0018\u00010\b¢\u0006\u0004\b\n\u0010\u000bJ\u0018\u0010\u0010\u001a\u00020\u00042\u0006\u0010\r\u001a\u00020\fH\u0080@¢\u0006\u0004\b\u000e\u0010\u000fJ\u0019\u0010\u0014\u001a\u00020\u00132\b\b\u0002\u0010\u0012\u001a\u00020\u0011H\u0002¢\u0006\u0004\b\u0014\u0010\u0015J\u000f\u0010\u0016\u001a\u00020\u0011H\u0002¢\u0006\u0004\b\u0016\u0010\u0017R\u001a\u0010\u0005\u001a\u00028\u00008\u0016X\u0096\u0004¢\u0006\f\n\u0004\b\u0005\u0010\u0018\u001a\u0004\b\u0019\u0010\u001aR\u0014\u0010\u001e\u001a\u00020\u001b8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u001c\u0010\u001dR\u0014\u0010 \u001a\u00020\u001b8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u001f\u0010\u001d¨\u0006!"}, d2 = {"Lio/ktor/network/sockets/SocketImpl;", "Ljava/nio/channels/SocketChannel;", "S", "Lio/ktor/network/sockets/NIOSocketImpl;", "Lio/ktor/network/sockets/Socket;", "channel", "Lio/ktor/network/selector/SelectorManager;", "selector", "Lio/ktor/network/sockets/SocketOptions$TCPClientSocketOptions;", "socketOptions", "<init>", "(Ljava/nio/channels/SocketChannel;Lio/ktor/network/selector/SelectorManager;Lio/ktor/network/sockets/SocketOptions$TCPClientSocketOptions;)V", "Ljava/net/SocketAddress;", "target", "connect$ktor_network", "(Ljava/net/SocketAddress;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "connect", "", "state", "", "wantConnect", "(Z)V", "inetSelfConnect", "()Z", "Ljava/nio/channels/SocketChannel;", "getChannel", "()Ljava/nio/channels/SocketChannel;", "Lio/ktor/network/sockets/SocketAddress;", "getLocalAddress", "()Lio/ktor/network/sockets/SocketAddress;", "localAddress", "getRemoteAddress", "remoteAddress", "ktor-network"}, k = 1, mv = {2, 1, 0}, xi = 48)
public final class SocketImpl<S extends SocketChannel> extends NIOSocketImpl<S> implements Socket {
private final S channel;
public SocketImpl(SocketChannel socketChannel, SelectorManager selectorManager, SocketOptions.TCPClientSocketOptions tCPClientSocketOptions, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(socketChannel, selectorManager, (i & 4) != 0 ? null : tCPClientSocketOptions);
}
@Override
public S getChannel() {
return this.channel;
}
public SocketImpl(S channel, SelectorManager selector, SocketOptions.TCPClientSocketOptions tCPClientSocketOptions) {
super(channel, selector, null, tCPClientSocketOptions);
Intrinsics.checkNotNullParameter(channel, "channel");
Intrinsics.checkNotNullParameter(selector, "selector");
this.channel = channel;
if (getChannel().isBlocking()) {
throw new IllegalArgumentException("Channel need to be configured as non-blocking.".toString());
}
}
@Override
public SocketAddress getLocalAddress() {
java.net.SocketAddress localSocketAddress;
SocketAddress socketAddress;
if (JavaSocketOptionsKt.getJava7NetworkApisAvailable()) {
localSocketAddress = getChannel().getLocalAddress();
} else {
localSocketAddress = getChannel().socket().getLocalSocketAddress();
}
if (localSocketAddress == null || (socketAddress = JavaSocketAddressUtilsKt.toSocketAddress(localSocketAddress)) == null) {
throw new IllegalStateException("Channel is not yet bound");
}
return socketAddress;
}
@Override
public SocketAddress getRemoteAddress() {
java.net.SocketAddress remoteSocketAddress;
SocketAddress socketAddress;
if (JavaSocketOptionsKt.getJava7NetworkApisAvailable()) {
remoteSocketAddress = getChannel().getRemoteAddress();
} else {
remoteSocketAddress = getChannel().socket().getRemoteSocketAddress();
}
if (remoteSocketAddress == null || (socketAddress = JavaSocketAddressUtilsKt.toSocketAddress(remoteSocketAddress)) == null) {
throw new IllegalStateException("Channel is not yet connected");
}
return socketAddress;
}
public final java.lang.Object connect$ktor_network(java.net.SocketAddress r6, kotlin.coroutines.Continuation<? super io.ktor.network.sockets.Socket> r7) {
throw new UnsupportedOperationException("Method not decompiled: io.ktor.network.sockets.SocketImpl.connect$ktor_network(java.net.SocketAddress, kotlin.coroutines.Continuation):java.lang.Object");
}
static void wantConnect$default(SocketImpl socketImpl, boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = true;
}
socketImpl.wantConnect(z);
}
private final void wantConnect(boolean state) {
interestOp(SelectInterest.CONNECT, state);
}
private final boolean inetSelfConnect() {
java.net.SocketAddress localSocketAddress;
java.net.SocketAddress remoteSocketAddress;
String str;
InetAddress address;
InetAddress address2;
String hostAddress;
InetAddress address3;
if (JavaSocketOptionsKt.getJava7NetworkApisAvailable()) {
localSocketAddress = getChannel().getLocalAddress();
} else {
localSocketAddress = getChannel().socket().getLocalSocketAddress();
}
if (JavaSocketOptionsKt.getJava7NetworkApisAvailable()) {
remoteSocketAddress = getChannel().getRemoteAddress();
} else {
remoteSocketAddress = getChannel().socket().getRemoteSocketAddress();
}
if (localSocketAddress == null || remoteSocketAddress == null) {
throw new IllegalStateException("localAddress and remoteAddress should not be null.");
}
java.net.InetSocketAddress inetSocketAddress = localSocketAddress instanceof java.net.InetSocketAddress ? (java.net.InetSocketAddress) localSocketAddress : null;
java.net.InetSocketAddress inetSocketAddress2 = remoteSocketAddress instanceof java.net.InetSocketAddress ? (java.net.InetSocketAddress) remoteSocketAddress : null;
if (inetSocketAddress == null && inetSocketAddress2 == null) {
return false;
}
String str2 = "";
if (inetSocketAddress == null || (address3 = inetSocketAddress.getAddress()) == null || (str = address3.getHostAddress()) == null) {
str = "";
}
if (inetSocketAddress2 != null && (address2 = inetSocketAddress2.getAddress()) != null && (hostAddress = address2.getHostAddress()) != null) {
str2 = hostAddress;
}
return Intrinsics.areEqual(inetSocketAddress != null ? Integer.valueOf(inetSocketAddress.getPort()) : null, inetSocketAddress2 != null ? Integer.valueOf(inetSocketAddress2.getPort()) : null) && (((inetSocketAddress2 == null || (address = inetSocketAddress2.getAddress()) == null) ? false : address.isAnyLocalAddress()) || Intrinsics.areEqual(str, str2));
}
}