Class SocketFactoryImpl

  • Direct Known Subclasses:
    TrustAllSslSocketFactory

    public class SocketFactoryImpl
    extends javax.net.SocketFactory
    Extends the SocketFactory object with the main functionality being that the created sockets inherit a set of options whose values are set in the SocketFactoryImpl.
     1.  SO_KEEPALIVE          - is keepalive enabled?
     2.  OOBINLINE             - is out of band in-line enabled?
     3.  SO_REUSEADDR          - should the address be reused?
     4.  TCP_NODELAY           - should data buffering for tcp be used?
     5.  SO_RCVBUF             - size of receive buffer
     6.  SO_SNDBUF             - size of send buffer
     7.  SO_TIMEOUT            - read timeout (millisecs)
     8.  SO_CONNECT_TIMEOUT    - connect timeout (millisecs)
     9.  SO_LINGER             - is lingering enabled?
     10. LINGER                - amount of time to linger (seconds)
     
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int LINGER
      amount of time to linger
      static boolean OOBINLINE
      is out of band in-line enabled
      static int SO_CONNECT_TIMEOUT
      connect timeout in milliseconds
      static boolean SO_KEEPALIVE
      should keep alives be sent
      static boolean SO_LINGER
      enabling lingering with 0-timeout will cause the socket to be closed forcefully upon execution of close()
      static int SO_RCVBUF
      size of receiving buffer
      static boolean SO_REUSEADDR
      should the address be reused
      static int SO_SNDBUF
      size of sending buffer iff needed
      static int SO_TIMEOUT
      read timeout in milliseconds
      static boolean TCP_NODELAY
      do not buffer send(s) iff true
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.net.Socket applySettings​(java.net.Socket s)
      Applies the current settings to the given socket.
      java.net.Socket createSocket()  
      java.net.Socket createSocket​(java.lang.String host, int port)  
      java.net.Socket createSocket​(java.lang.String host, int port, java.net.InetAddress local, int localPort)  
      java.net.Socket createSocket​(java.net.InetAddress host, int port)  
      java.net.Socket createSocket​(java.net.InetAddress host, int port, java.net.InetAddress local, int localPort)  
      static javax.net.SocketFactory getDefault()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SO_KEEPALIVE

        public static final boolean SO_KEEPALIVE
        should keep alives be sent
        See Also:
        Constant Field Values
      • OOBINLINE

        public static final boolean OOBINLINE
        is out of band in-line enabled
        See Also:
        Constant Field Values
      • SO_REUSEADDR

        public static final boolean SO_REUSEADDR
        should the address be reused
        See Also:
        Constant Field Values
      • TCP_NODELAY

        public static final boolean TCP_NODELAY
        do not buffer send(s) iff true
        See Also:
        Constant Field Values
      • SO_SNDBUF

        public static final int SO_SNDBUF
        size of sending buffer iff needed
        See Also:
        Constant Field Values
      • SO_TIMEOUT

        public static final int SO_TIMEOUT
        read timeout in milliseconds
        See Also:
        Constant Field Values
      • SO_CONNECT_TIMEOUT

        public static final int SO_CONNECT_TIMEOUT
        connect timeout in milliseconds
        See Also:
        Constant Field Values
      • SO_LINGER

        public static final boolean SO_LINGER
        enabling lingering with 0-timeout will cause the socket to be closed forcefully upon execution of close()
        See Also:
        Constant Field Values
    • Constructor Detail

      • SocketFactoryImpl

        public SocketFactoryImpl()
    • Method Detail

      • createSocket

        public java.net.Socket createSocket()
                                     throws java.io.IOException
        Overrides:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • applySettings

        protected java.net.Socket applySettings​(java.net.Socket s)
        Applies the current settings to the given socket.
        Parameters:
        s - Socket to apply the settings to
        Returns:
        Socket the input socket
      • createSocket

        public java.net.Socket createSocket​(java.lang.String host,
                                            int port)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.net.InetAddress host,
                                            int port)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String host,
                                            int port,
                                            java.net.InetAddress local,
                                            int localPort)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.net.InetAddress host,
                                            int port,
                                            java.net.InetAddress local,
                                            int localPort)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • getDefault

        public static javax.net.SocketFactory getDefault()
        See Also:
        SocketFactory.getDefault()