Class Socket


  • public class Socket
    extends FileDescriptor
    Provides a JNI bridge to native socket operations. Internal usage only!
    • Field Detail

      • UDS_SUN_PATH_SIZE

        @Deprecated
        public static final int UDS_SUN_PATH_SIZE
        Deprecated.
        See Also:
        Constant Field Values
      • ipv6

        protected final boolean ipv6
      • INITIALIZED

        private static final java.util.concurrent.atomic.AtomicBoolean INITIALIZED
    • Constructor Detail

      • Socket

        public Socket​(int fd)
    • Method Detail

      • useIpv6

        private boolean useIpv6​(java.net.InetAddress address)
        Returns true if we should use IPv6 internally, false otherwise.
      • shutdown

        public final void shutdown()
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • shutdown

        public final void shutdown​(boolean read,
                                   boolean write)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • isShutdown

        public final boolean isShutdown()
      • isInputShutdown

        public final boolean isInputShutdown()
      • isOutputShutdown

        public final boolean isOutputShutdown()
      • sendTo

        public final int sendTo​(java.nio.ByteBuffer buf,
                                int pos,
                                int limit,
                                java.net.InetAddress addr,
                                int port)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • sendTo

        public final int sendTo​(java.nio.ByteBuffer buf,
                                int pos,
                                int limit,
                                java.net.InetAddress addr,
                                int port,
                                boolean fastOpen)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • sendToAddress

        public final int sendToAddress​(long memoryAddress,
                                       int pos,
                                       int limit,
                                       java.net.InetAddress addr,
                                       int port)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • sendToAddress

        public final int sendToAddress​(long memoryAddress,
                                       int pos,
                                       int limit,
                                       java.net.InetAddress addr,
                                       int port,
                                       boolean fastOpen)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • sendToAddresses

        public final int sendToAddresses​(long memoryAddress,
                                         int length,
                                         java.net.InetAddress addr,
                                         int port)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • sendToAddresses

        public final int sendToAddresses​(long memoryAddress,
                                         int length,
                                         java.net.InetAddress addr,
                                         int port,
                                         boolean fastOpen)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • recvFrom

        public final DatagramSocketAddress recvFrom​(java.nio.ByteBuffer buf,
                                                    int pos,
                                                    int limit)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • recvFromAddress

        public final DatagramSocketAddress recvFromAddress​(long memoryAddress,
                                                           int pos,
                                                           int limit)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • recvFd

        public final int recvFd()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • sendFd

        public final int sendFd​(int fdToSend)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • connect

        public final boolean connect​(java.net.SocketAddress socketAddress)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • finishConnect

        public final boolean finishConnect()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • disconnect

        public final void disconnect()
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • bind

        public final void bind​(java.net.SocketAddress socketAddress)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • listen

        public final void listen​(int backlog)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • accept

        public final int accept​(byte[] addr)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • remoteAddress

        public final java.net.InetSocketAddress remoteAddress()
      • localAddress

        public final java.net.InetSocketAddress localAddress()
      • getReceiveBufferSize

        public final int getReceiveBufferSize()
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • getSendBufferSize

        public final int getSendBufferSize()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • isKeepAlive

        public final boolean isKeepAlive()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • isTcpNoDelay

        public final boolean isTcpNoDelay()
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • isReuseAddress

        public final boolean isReuseAddress()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • isReusePort

        public final boolean isReusePort()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • isBroadcast

        public final boolean isBroadcast()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • getSoLinger

        public final int getSoLinger()
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getSoError

        public final int getSoError()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getTrafficClass

        public final int getTrafficClass()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setKeepAlive

        public final void setKeepAlive​(boolean keepAlive)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • setReceiveBufferSize

        public final void setReceiveBufferSize​(int receiveBufferSize)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setSendBufferSize

        public final void setSendBufferSize​(int sendBufferSize)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • setTcpNoDelay

        public final void setTcpNoDelay​(boolean tcpNoDelay)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • setSoLinger

        public final void setSoLinger​(int soLinger)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • setReuseAddress

        public final void setReuseAddress​(boolean reuseAddress)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • setReusePort

        public final void setReusePort​(boolean reusePort)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • setBroadcast

        public final void setBroadcast​(boolean broadcast)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • setTrafficClass

        public final void setTrafficClass​(int trafficClass)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • isIPv6Preferred

        public static boolean isIPv6Preferred()
      • isIPv6

        private static boolean isIPv6​(int fd)
      • newSocketStream

        public static Socket newSocketStream()
      • newSocketDgram

        public static Socket newSocketDgram()
      • newSocketDomain

        public static Socket newSocketDomain()
      • initialize

        public static void initialize()
      • newSocketStream0

        protected static int newSocketStream0()
      • newSocketStream0

        protected static int newSocketStream0​(boolean ipv6)
      • newSocketDgram0

        protected static int newSocketDgram0()
      • newSocketDgram0

        protected static int newSocketDgram0​(boolean ipv6)
      • newSocketDomain0

        protected static int newSocketDomain0()
      • shutdown

        private static int shutdown​(int fd,
                                    boolean read,
                                    boolean write)
      • connect

        private static int connect​(int fd,
                                   boolean ipv6,
                                   byte[] address,
                                   int scopeId,
                                   int port)
      • connectDomainSocket

        private static int connectDomainSocket​(int fd,
                                               byte[] path)
      • finishConnect

        private static int finishConnect​(int fd)
      • disconnect

        private static int disconnect​(int fd,
                                      boolean ipv6)
      • bind

        private static int bind​(int fd,
                                boolean ipv6,
                                byte[] address,
                                int scopeId,
                                int port)
      • bindDomainSocket

        private static int bindDomainSocket​(int fd,
                                            byte[] path)
      • listen

        private static int listen​(int fd,
                                  int backlog)
      • accept

        private static int accept​(int fd,
                                  byte[] addr)
      • remoteAddress

        private static byte[] remoteAddress​(int fd)
      • localAddress

        private static byte[] localAddress​(int fd)
      • sendTo

        private static int sendTo​(int fd,
                                  boolean ipv6,
                                  java.nio.ByteBuffer buf,
                                  int pos,
                                  int limit,
                                  byte[] address,
                                  int scopeId,
                                  int port,
                                  int flags)
      • sendToAddress

        private static int sendToAddress​(int fd,
                                         boolean ipv6,
                                         long memoryAddress,
                                         int pos,
                                         int limit,
                                         byte[] address,
                                         int scopeId,
                                         int port,
                                         int flags)
      • sendToAddresses

        private static int sendToAddresses​(int fd,
                                           boolean ipv6,
                                           long memoryAddress,
                                           int length,
                                           byte[] address,
                                           int scopeId,
                                           int port,
                                           int flags)
      • recvFrom

        private static DatagramSocketAddress recvFrom​(int fd,
                                                      java.nio.ByteBuffer buf,
                                                      int pos,
                                                      int limit)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • recvFromAddress

        private static DatagramSocketAddress recvFromAddress​(int fd,
                                                             long memoryAddress,
                                                             int pos,
                                                             int limit)
                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • recvFd

        private static int recvFd​(int fd)
      • sendFd

        private static int sendFd​(int socketFd,
                                  int fd)
      • msgFastopen

        private static int msgFastopen()
      • newSocketStreamFd

        private static int newSocketStreamFd​(boolean ipv6)
      • newSocketDgramFd

        private static int newSocketDgramFd​(boolean ipv6)
      • newSocketDomainFd

        private static int newSocketDomainFd()
      • isReuseAddress

        private static int isReuseAddress​(int fd)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • isReusePort

        private static int isReusePort​(int fd)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getReceiveBufferSize

        private static int getReceiveBufferSize​(int fd)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • getSendBufferSize

        private static int getSendBufferSize​(int fd)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • isKeepAlive

        private static int isKeepAlive​(int fd)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • isTcpNoDelay

        private static int isTcpNoDelay​(int fd)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • isBroadcast

        private static int isBroadcast​(int fd)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getSoLinger

        private static int getSoLinger​(int fd)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getSoError

        private static int getSoError​(int fd)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • getTrafficClass

        private static int getTrafficClass​(int fd,
                                           boolean ipv6)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • setReuseAddress

        private static void setReuseAddress​(int fd,
                                            int reuseAddress)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • setReusePort

        private static void setReusePort​(int fd,
                                         int reuseAddress)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setKeepAlive

        private static void setKeepAlive​(int fd,
                                         int keepAlive)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setReceiveBufferSize

        private static void setReceiveBufferSize​(int fd,
                                                 int receiveBufferSize)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • setSendBufferSize

        private static void setSendBufferSize​(int fd,
                                              int sendBufferSize)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • setTcpNoDelay

        private static void setTcpNoDelay​(int fd,
                                          int tcpNoDelay)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • setSoLinger

        private static void setSoLinger​(int fd,
                                        int soLinger)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • setBroadcast

        private static void setBroadcast​(int fd,
                                         int broadcast)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setTrafficClass

        private static void setTrafficClass​(int fd,
                                            boolean ipv6,
                                            int trafficClass)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • initialize

        private static void initialize​(boolean ipv4Preferred)