Class SocketUtils

java.lang.Object
org.apache.nifi.io.socket.SocketUtils

public final class SocketUtils extends Object
  • Field Details

    • logger

      private static final org.slf4j.Logger logger
  • Constructor Details

    • SocketUtils

      public SocketUtils()
  • Method Details

    • createSocket

      public static Socket createSocket(InetSocketAddress address, SocketConfiguration config) throws IOException
      Returns a Socket (effectively used as a client socket) for the given address and configuration.
      Parameters:
      address - the InetSocketAddress for the socket (used for hostname and port)
      config - the SocketConfiguration
      Returns:
      the socket (can be configured for SSL)
      Throws:
      IOException - if there is a problem creating the socket
    • createServerSocket

      public static ServerSocket createServerSocket(int port, ServerSocketConfiguration config) throws IOException, TlsException
      Returns a ServerSocket for the given port and configuration.
      Parameters:
      port - the port for the socket
      config - the ServerSocketConfiguration
      Returns:
      the server socket (can be configured for SSL)
      Throws:
      IOException - if there is a problem creating the socket
      TlsException - if there is a problem creating the socket
    • closeQuietly

      public static void closeQuietly(Socket socket)
    • closeQuietly

      public static void closeQuietly(ServerSocket serverSocket)
    • isTlsError

      public static boolean isTlsError(Throwable e)
      Returns true if this exception is due to a TLS problem (either directly or because of its cause, if present). Traverses the cause chain recursively.
      Parameters:
      e - the exception to evaluate
      Returns:
      true if the direct or indirect cause of this exception was TLS-related