java.net.SocketImpl Java Examples

The following examples show how to use java.net.SocketImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSocketServlet.java    From appengine-java-vm-runtime with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #2
Source File: SocketChannelTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #3
Source File: Sdp.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #4
Source File: TestSocketServlet.java    From appengine-java-vm-runtime with Apache License 2.0 4 votes vote down vote up
@Override
protected void accept(SocketImpl s) throws IOException {}
 
Example #5
Source File: FileDescriptorHolderSocketImpl.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Override
protected void accept(SocketImpl s) throws IOException {
    throw new UnsupportedOperationException();
}
 
Example #6
Source File: Sdp.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #7
Source File: Sdp.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #8
Source File: Sdp.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #9
Source File: SocketAdaptor.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
Example #10
Source File: Sdp.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #11
Source File: Sdp.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #12
Source File: Sdp.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #13
Source File: Sdp.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #14
Source File: NioSocketImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
    }
}
 
Example #15
Source File: DummySocketImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
protected void accept(SocketImpl si) {
    shouldNotGetHere();
}
 
Example #16
Source File: HttpProxyAwareSocket.java    From cyberduck with GNU General Public License v3.0 4 votes vote down vote up
public HttpProxyAwareSocket(final SocketImpl impl, final Proxy proxy) throws SocketException {
    super(impl);
    this.proxy = proxy;
}
 
Example #17
Source File: SocketAdaptor.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
Example #18
Source File: SocketAdaptor.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
Example #19
Source File: Sdp.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #20
Source File: Sdp.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #21
Source File: SocketAdaptor.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
    super((SocketImpl) null);
    this.sc = sc;
}
 
Example #22
Source File: Sdp.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #23
Source File: DummySocketImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static SocketImpl create() {
    return new DummySocketImpl();
}
 
Example #24
Source File: Sdp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
SdpSocket(SocketImpl impl) throws SocketException {
    super(impl);
}
 
Example #25
Source File: AndroidNetworkLibrary.java    From cronet with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void accept(SocketImpl s) {
    throw new RuntimeException("accept not implemented");
}
 
Example #26
Source File: Sdp.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example #27
Source File: Sdp.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example #28
Source File: Sdp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example #29
Source File: JavaNetSocketAccess.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Creates a ServerSocket associated with the given SocketImpl.
 */
ServerSocket newServerSocket(SocketImpl impl);
 
Example #30
Source File: Sdp.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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);
}