Package org.apache.nifi.io.socket
Class SocketUtils
java.lang.Object
org.apache.nifi.io.socket.SocketUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
closeQuietly
(ServerSocket serverSocket) static void
closeQuietly
(Socket socket) static ServerSocket
createServerSocket
(int port, ServerSocketConfiguration config) Returns aServerSocket
for the given port and configuration.static Socket
createSocket
(InetSocketAddress address, SocketConfiguration config) Returns aSocket
(effectively used as a client socket) for the given address and configuration.static boolean
Returnstrue
if this exception is due to a TLS problem (either directly or because of its cause, if present).
-
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 aSocket
(effectively used as a client socket) for the given address and configuration.- Parameters:
address
- theInetSocketAddress
for the socket (used for hostname and port)config
- theSocketConfiguration
- 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 aServerSocket
for the given port and configuration.- Parameters:
port
- the port for the socketconfig
- theServerSocketConfiguration
- Returns:
- the server socket (can be configured for SSL)
- Throws:
IOException
- if there is a problem creating the socketTlsException
- if there is a problem creating the socket
-
closeQuietly
-
closeQuietly
-
isTlsError
Returnstrue
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
-