Socket extends FileDescriptor { public static Socket newSocketStream() { int res = newSocketStreamFd(); if (res < 0) { throw new ChannelException(newIOException("newSocketStream", res)); } return new Socket(res); } Socket(int fd); void shutdown(); void shutdown(boolean read, boolean write); boolean isShutdown(); boolean isInputShutdown(); boolean isOutputShutdown(); int sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port); int sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port); int sendToAddresses(long memoryAddress, int length, InetAddress addr, int port); DatagramSocketAddress recvFrom(ByteBuffer buf, int pos, int limit); DatagramSocketAddress recvFromAddress(long memoryAddress, int pos, int limit); boolean connect(SocketAddress socketAddress); boolean finishConnect(); void bind(SocketAddress socketAddress); void listen(int backlog); int accept(byte[] addr); InetSocketAddress remoteAddress(); InetSocketAddress localAddress(); int getReceiveBufferSize(); int getSendBufferSize(); boolean isKeepAlive(); boolean isTcpNoDelay(); boolean isTcpCork(); int getSoLinger(); int getSoError(); void setKeepAlive(boolean keepAlive); void setReceiveBufferSize(int receiveBufferSize); void setSendBufferSize(int sendBufferSize); void setTcpNoDelay(boolean tcpNoDelay); void setTcpCork(boolean tcpCork); void setSoLinger(int soLinger); @Override String toString(); static Socket newSocketStream(); static Socket newSocketDgram(); static Socket newSocketDomain();  }
@Test public void testDoubleCloseDoesNotThrow() throws IOException { Socket socket = Socket.newSocketStream(); socket.close(); socket.close(); }