public class NetUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static ServerSocket |
closeSilently(ServerSocket socket)
Close a server socket and ignore any exceptions.
|
static Socket |
createLoopbackSocket(int port,
boolean ssl)
Create a loopback socket (a socket that is connected to localhost) on
this port.
|
static ServerSocket |
createServerSocket(int port,
boolean ssl)
Create a server socket.
|
static Socket |
createSocket(InetAddress address,
int port,
boolean ssl)
Create a client socket that is connected to the given address and port.
|
static Socket |
createSocket(String server,
int defaultPort,
boolean ssl)
Create a client socket that is connected to the given address and port.
|
static String |
getLocalAddress()
Get the local host address as a string.
|
static boolean |
isLocalAddress(Socket socket)
Check if a socket is connected to a local address.
|
public static Socket createLoopbackSocket(int port, boolean ssl) throws IOException
port - the portssl - if SSL should be usedIOExceptionpublic static Socket createSocket(String server, int defaultPort, boolean ssl) throws IOException
server - to connect to (including an optional port)defaultPort - the default port (if not specified in the server
address)ssl - if SSL should be usedIOExceptionpublic static Socket createSocket(InetAddress address, int port, boolean ssl) throws IOException
address - the address to connect toport - the portssl - if SSL should be usedIOExceptionpublic static ServerSocket createServerSocket(int port, boolean ssl)
port - the port to listen onssl - if SSL should be usedpublic static boolean isLocalAddress(Socket socket) throws UnknownHostException
socket - the socketUnknownHostExceptionpublic static ServerSocket closeSilently(ServerSocket socket)
socket - the socketpublic static String getLocalAddress()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.