public class NetUtil extends Object
getAllLocalIPs()
method was taken from the Apache Curator project
which is also under the Apache 2.0 license.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TCP_BACKLOG_LINUX |
static int |
DEFAULT_TCP_BACKLOG_WINDOWS |
static String |
TCP_BACKLOG_SETTING_LOCATION |
Constructor and Description |
---|
NetUtil() |
Modifier and Type | Method and Description |
---|---|
static Collection<InetAddress> |
getAllLocalIPs()
based on http://pastebin.com/5X073pUc
|
static int |
getDefaultTcpBacklog() |
static LocalIpFilter |
getLocalIpFilter()
Return the current local ip filter used by
getAllLocalIPs() |
static int |
getTcpBacklog()
The SOMAXCONN value of the current machine.
|
static int |
getTcpBacklog(int tcpBacklog)
The SOMAXCONN value of the current machine.
|
static boolean |
isWindows() |
static void |
setLocalIpFilter(LocalIpFilter newLocalIpFilter)
Replace the default local ip filter used by
getAllLocalIPs() |
public static final int DEFAULT_TCP_BACKLOG_WINDOWS
public static final int DEFAULT_TCP_BACKLOG_LINUX
public static final String TCP_BACKLOG_SETTING_LOCATION
public static int getTcpBacklog()
200
is used as a
default value for Windows or 128
for others.public static int getTcpBacklog(int tcpBacklog)
defaultBacklog
argument is
usedpublic static boolean isWindows()
public static int getDefaultTcpBacklog()
public static void setLocalIpFilter(LocalIpFilter newLocalIpFilter)
getAllLocalIPs()
newLocalIpFilter
- the new local ip filterpublic static LocalIpFilter getLocalIpFilter()
getAllLocalIPs()
public static Collection<InetAddress> getAllLocalIPs() throws SocketException
Returns all available IP addresses.
In error case or if no network connection is established, we return an empty list here.
Loopback addresses are excluded - so 127.0.0.1 will not be never returned.
The "primary" IP might not be the first one in the returned list.
SocketException
- errorsCopyright © 2020. All rights reserved.