code: public static synchronized void setSocketFactory(SocketImplFactory fac) throws IOException {
          if (factory != null) {
              throw new SocketException("factory already defined");
          }
          SecurityManager security = System.getSecurityManager();
          if (security != null) {
              security.checkSetFactory();
          }
          factory = fac;
      }
docs: Sets the server socket implementation factory for the
  application. The factory can be specified only once.
  <p>
  When an application creates a new server socket, the socket
  implementation factory's <code>createSocketImpl</code> method is
  called to create the actual socket implementation.
  <p>
  Passing <code>null</code> to the method is a no-op unless the factory
  was already set.
  <p>
  If there is a security manager, this method first calls
  the security manager's <code>checkSetFactory</code> method
  to ensure the operation is allowed.
  This could result in a SecurityException.
  
  @param      fac   the desired factory.
  @exception  IOException  if an I/O error occurs when setting the
  socket factory.
  @exception  SocketException  if the factory has already been defined.
  @exception  SecurityException  if a security manager exists and its
  <code>checkSetFactory</code> method doesn't allow the operation.
  @see        java.net.SocketImplFactory#createSocketImpl()
  @see        SecurityManager#checkSetFactory