Package io.dropwizard.jetty
Class NetUtil
- java.lang.Object
-
- io.dropwizard.jetty.NetUtil
-
public class NetUtil extends Object
This class is taken from the Netty project, and all credit goes to them. It has been modified, to remove dependencies on other classes, and to convert to methods, rather than a static value. ThegetAllLocalIPs()method was taken from the Apache Curator project which is also under the Apache 2.0 license.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_TCP_BACKLOG_LINUXstatic intDEFAULT_TCP_BACKLOG_WINDOWSstatic StringTCP_BACKLOG_SETTING_LOCATION
-
Constructor Summary
Constructors Constructor Description NetUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Collection<InetAddress>getAllLocalIPs()based on http://pastebin.com/5X073pUcstatic intgetDefaultTcpBacklog()static LocalIpFiltergetLocalIpFilter()Return the current local ip filter used bygetAllLocalIPs()static intgetTcpBacklog()The SOMAXCONN value of the current machine.static intgetTcpBacklog(int tcpBacklog)The SOMAXCONN value of the current machine.static booleanisWindows()static voidsetLocalIpFilter(LocalIpFilter newLocalIpFilter)Replace the default local ip filter used bygetAllLocalIPs()
-
-
-
Field Detail
-
DEFAULT_TCP_BACKLOG_WINDOWS
public static final int DEFAULT_TCP_BACKLOG_WINDOWS
- See Also:
- Constant Field Values
-
DEFAULT_TCP_BACKLOG_LINUX
public static final int DEFAULT_TCP_BACKLOG_LINUX
- See Also:
- Constant Field Values
-
TCP_BACKLOG_SETTING_LOCATION
public static final String TCP_BACKLOG_SETTING_LOCATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTcpBacklog
public static int getTcpBacklog()
The SOMAXCONN value of the current machine. If failed to get the value,200is used as a default value for Windows or128for others.
-
getTcpBacklog
public static int getTcpBacklog(int tcpBacklog)
The SOMAXCONN value of the current machine. If failed to get the value,defaultBacklogargument is used
-
isWindows
public static boolean isWindows()
-
getDefaultTcpBacklog
public static int getDefaultTcpBacklog()
-
setLocalIpFilter
public static void setLocalIpFilter(LocalIpFilter newLocalIpFilter)
Replace the default local ip filter used bygetAllLocalIPs()- Parameters:
newLocalIpFilter- the new local ip filter
-
getLocalIpFilter
public static LocalIpFilter getLocalIpFilter()
Return the current local ip filter used bygetAllLocalIPs()- Returns:
- ip filter
-
getAllLocalIPs
public static Collection<InetAddress> getAllLocalIPs() throws SocketException
based on http://pastebin.com/5X073pUcReturns 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.
- Returns:
- Returns all IP addresses (can be an empty list in error case or if network connection is missing).
- Throws:
SocketException- errors- See Also:
- getAllLocalIPs, ServiceInstanceBuilder.java
-
-