类java.net.SocketImpl源码实例Demo

下面列出了怎么用java.net.SocketImpl的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: j2objc   文件: SocketChannelTest.java
public void test_Socket_impl_notNull() throws Exception {
    try (SocketChannel sc = SocketChannel.open();
         Socket socket = sc.socket()) {
        Field f_impl = Socket.class.getDeclaredField("impl");
        f_impl.setAccessible(true);
        Object implFieldValue = f_impl.get(socket);
        assertNotNull(implFieldValue);
        assertTrue(implFieldValue instanceof SocketImpl);
    }
}
 
private void testSetSocketImpl(HttpServletResponse response)
    throws IOException, AssertionFailedException {
  SocketImplFactory mockFactory =
      new SocketImplFactory() {
        @Override
        public SocketImpl createSocketImpl() {
          return null;
        }
      };

  SocketException caught = null;
  try {
    Socket.setSocketImplFactory(mockFactory);
  } catch (SocketException e) {
    caught = e;
  }
  assertNotNull("caught", caught, response);
}
 
源代码3 项目: dragonwell8_jdk   文件: SocketAdaptor.java
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
源代码4 项目: dragonwell8_jdk   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码5 项目: TencentKona-8   文件: SocketAdaptor.java
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
源代码6 项目: TencentKona-8   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码7 项目: jdk8u60   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码8 项目: openjdk-jdk8u   文件: SocketAdaptor.java
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
源代码9 项目: openjdk-jdk8u   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码10 项目: cronet   文件: AndroidNetworkLibrary.java
@Override
protected void accept(SocketImpl s) {
    throw new RuntimeException("accept not implemented");
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码12 项目: cyberduck   文件: HttpProxyAwareSocket.java
public HttpProxyAwareSocket(final SocketImpl impl, final Proxy proxy) throws SocketException {
    super(impl);
    this.proxy = proxy;
}
 
源代码13 项目: Bytecoder   文件: DummySocketImpl.java
static SocketImpl create() {
    return new DummySocketImpl();
}
 
源代码14 项目: Bytecoder   文件: DummySocketImpl.java
@Override
protected void accept(SocketImpl si) {
    shouldNotGetHere();
}
 
源代码15 项目: Bytecoder   文件: NioSocketImpl.java
/**
 * Accepts a new connection so that the given SocketImpl is connected to
 * the peer. The SocketImpl must be a newly created NioSocketImpl.
 */
@Override
protected void accept(SocketImpl si) throws IOException {
    NioSocketImpl nsi = (NioSocketImpl) si;
    if (nsi.state != ST_NEW)
        throw new SocketException("Not a newly created SocketImpl");

    FileDescriptor newfd = new FileDescriptor();
    InetSocketAddress[] isaa = new InetSocketAddress[1];

    // acquire the lock, adjusting the timeout for cases where several
    // threads are accepting connections and there is a timeout set
    ReentrantLock acceptLock = readLock;
    int timeout = this.timeout;
    long remainingNanos = 0;
    if (timeout > 0) {
        remainingNanos = tryLock(acceptLock, timeout, MILLISECONDS);
        if (remainingNanos <= 0) {
            assert !acceptLock.isHeldByCurrentThread();
            throw new SocketTimeoutException("Accept timed out");
        }
    } else {
        acceptLock.lock();
    }

    // accept a connection
    try {
        int n = 0;
        FileDescriptor fd = beginAccept();
        try {
            if (remainingNanos > 0) {
                // accept with timeout
                configureNonBlocking(fd);
                n = timedAccept(fd, newfd, isaa, remainingNanos);
            } else {
                // accept, no timeout
                n = Net.accept(fd, newfd, isaa);
                while (IOStatus.okayToRetry(n) && isOpen()) {
                    park(fd, Net.POLLIN);
                    n = Net.accept(fd, newfd, isaa);
                }
            }
        } finally {
            endAccept(n > 0);
            assert IOStatus.check(n);
        }
    } finally {
        acceptLock.unlock();
    }

    // get local address and configure accepted socket to blocking mode
    InetSocketAddress localAddress;
    try {
        localAddress = Net.localAddress(newfd);
        IOUtil.configureBlocking(newfd, true);
    } catch (IOException ioe) {
        nd.close(newfd);
        throw ioe;
    }

    // set the fields
    Runnable closer = closerFor(newfd, true);
    synchronized (nsi.stateLock) {
        nsi.fd = newfd;
        nsi.stream = true;
        nsi.cleaner = CleanerFactory.cleaner().register(nsi, closer);
        nsi.localport = localAddress.getPort();
        nsi.address = isaa[0].getAddress();
        nsi.port = isaa[0].getPort();
        nsi.state = ST_CONNECTED;
    }
}
 
源代码16 项目: jdk8u-jdk   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码17 项目: hottub   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码18 项目: openjdk-8-source   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码19 项目: openjdk-8   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码20 项目: jdk8u_jdk   文件: SocketAdaptor.java
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
源代码21 项目: jdk8u_jdk   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码22 项目: jdk8u-jdk   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码23 项目: jdk8u-dev-jdk   文件: Sdp.java
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
源代码24 项目: j2objc   文件: FileDescriptorHolderSocketImpl.java
@Override
protected void accept(SocketImpl s) throws IOException {
    throw new UnsupportedOperationException();
}
 
@Override
protected void accept(SocketImpl s) throws IOException {}
 
源代码26 项目: dragonwell8_jdk   文件: Sdp.java
/**
 * Creates an unconnected and unbound SDP socket. The {@code Socket} is
 * associated with a {@link java.net.SocketImpl} of the system-default type.
 *
 * @return  a new Socket
 *
 * @throws  UnsupportedOperationException
 *          If SDP is not supported
 * @throws  IOException
 *          If an I/O error occurs
 */
public static Socket openSocket() throws IOException {
    SocketImpl impl = createSocketImpl();
    return new SdpSocket(impl);
}
 
源代码27 项目: TencentKona-8   文件: Sdp.java
/**
 * Creates an unconnected and unbound SDP socket. The {@code Socket} is
 * associated with a {@link java.net.SocketImpl} of the system-default type.
 *
 * @return  a new Socket
 *
 * @throws  UnsupportedOperationException
 *          If SDP is not supported
 * @throws  IOException
 *          If an I/O error occurs
 */
public static Socket openSocket() throws IOException {
    SocketImpl impl = createSocketImpl();
    return new SdpSocket(impl);
}
 
源代码28 项目: jdk8u60   文件: Sdp.java
/**
 * Creates an unconnected and unbound SDP socket. The {@code Socket} is
 * associated with a {@link java.net.SocketImpl} of the system-default type.
 *
 * @return  a new Socket
 *
 * @throws  UnsupportedOperationException
 *          If SDP is not supported
 * @throws  IOException
 *          If an I/O error occurs
 */
public static Socket openSocket() throws IOException {
    SocketImpl impl = createSocketImpl();
    return new SdpSocket(impl);
}
 
源代码29 项目: openjdk-jdk8u   文件: Sdp.java
/**
 * Creates an unconnected and unbound SDP socket. The {@code Socket} is
 * associated with a {@link java.net.SocketImpl} of the system-default type.
 *
 * @return  a new Socket
 *
 * @throws  UnsupportedOperationException
 *          If SDP is not supported
 * @throws  IOException
 *          If an I/O error occurs
 */
public static Socket openSocket() throws IOException {
    SocketImpl impl = createSocketImpl();
    return new SdpSocket(impl);
}
 
源代码30 项目: openjdk-jdk8u-backup   文件: Sdp.java
/**
 * Creates an unconnected and unbound SDP socket. The {@code Socket} is
 * associated with a {@link java.net.SocketImpl} of the system-default type.
 *
 * @return  a new Socket
 *
 * @throws  UnsupportedOperationException
 *          If SDP is not supported
 * @throws  IOException
 *          If an I/O error occurs
 */
public static Socket openSocket() throws IOException {
    SocketImpl impl = createSocketImpl();
    return new SdpSocket(impl);
}
 
 类所在包
 类方法
 同包方法