## org.h2.util
Class NetUtils

    java.lang.Object
      org.h2.util.NetUtils

    public class NetUtils

extends java.lang.Object

This utility class contains socket helper functions.

Method Summary
`static java.net.ServerSocket` `closeSilently(java.net.ServerSocket socket)` Close a server socket and ignore any exceptions.
`static java.net.Socket` `createLoopbackSocket(int port, boolean ssl)` Create a loopback socket (a socket that is connected to localhost) on this port.
`static java.net.ServerSocket` `createServerSocket(int port, boolean ssl)` Create a server socket.
`static java.net.Socket` `createSocket(java.net.InetAddress address, int port, boolean ssl)` Create a client socket that is connected to the given address and port.
`static java.net.Socket` `createSocket(java.lang.String server, int defaultPort, boolean ssl)` Create a client socket that is connected to the given address and port.
`static java.lang.String` `getHostName(java.lang.String localAddress)` Get the host name of a local address, if available.
`static java.lang.String` `getLocalAddress()` Get the local host address as a string.
`static boolean` `isLocalAddress(java.net.Socket socket)` Check if a socket is connected to a local address.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### createLoopbackSocket

    public static java.net.Socket createLoopbackSocket(int port,
                                                       boolean ssl)
                                                throws java.io.IOException

  Create a loopback socket (a socket that is connected to localhost) on this port.

  Parameters:
    `port` - the port
    `ssl` - if SSL should be used
  Returns:
    the socket
  Throws:
    `java.io.IOException`

### createSocket

    public static java.net.Socket createSocket(java.lang.String server,
                                               int defaultPort,
                                               boolean ssl)
                                        throws java.io.IOException

  Create a client socket that is connected to the given address and port.

  Parameters:
    `server` - to connect to (including an optional port)
    `defaultPort` - the default port (if not specified in the server address)
    `ssl` - if SSL should be used
  Returns:
    the socket
  Throws:
    `java.io.IOException`

### createSocket

    public static java.net.Socket createSocket(java.net.InetAddress address,
                                               int port,
                                               boolean ssl)
                                        throws java.io.IOException

  Create a client socket that is connected to the given address and port.

  Parameters:
    `address` - the address to connect to
    `port` - the port
    `ssl` - if SSL should be used
  Returns:
    the socket
  Throws:
    `java.io.IOException`

### createServerSocket

    public static java.net.ServerSocket createServerSocket(int port,
                                                           boolean ssl)

  Create a server socket. The system property h2.bindAddress is used if set.

  Parameters:
    `port` - the port to listen on
    `ssl` - if SSL should be used
  Returns:
    the server socket

### isLocalAddress

    public static boolean isLocalAddress(java.net.Socket socket)
                                  throws java.net.UnknownHostException

  Check if a socket is connected to a local address.

  Parameters:
    `socket` - the socket
  Returns:
    true if it is
  Throws:
    `java.net.UnknownHostException`

### closeSilently

    public static java.net.ServerSocket closeSilently(java.net.ServerSocket socket)

  Close a server socket and ignore any exceptions.

  Parameters:
    `socket` - the socket
  Returns:
    null

### getLocalAddress

    public static java.lang.String getLocalAddress()

  Get the local host address as a string. For performance, the result is cached for one second.

  Returns:
    the local host address

### getHostName

    public static java.lang.String getHostName(java.lang.String localAddress)

  Get the host name of a local address, if available.

  Parameters:
    `localAddress` - the local address
  Returns:
    the host name, or another text if not available