Interface NetUtil


  • public interface NetUtil
    Created by kurila on 11.07.16.
    • Method Summary

      Static Methods 
      Modifier and Type Method Description
      static java.lang.String addPortIfMissing​(java.lang.String addr, int defaultPort)  
      static java.net.InetAddress getHostAddr()
      Tries to resolve 1st enabled external network interface IP address.
      static long getHostAddrCode()  
      static java.lang.String getHostAddrString()  
    • Method Detail

      • getHostAddr

        static java.net.InetAddress getHostAddr()
                                         throws java.net.SocketException
        Tries to resolve 1st enabled external network interface IP address. Tries to fall back to loopback interface if no valid external interface found.
        Returns:
        IP address
        Throws:
        java.net.SocketException - if failed to resolve an interface address
        java.lang.IllegalStateException - if no network interface found
      • getHostAddrString

        static java.lang.String getHostAddrString()
                                           throws java.net.SocketException,
                                                  java.lang.IllegalStateException
        Throws:
        java.net.SocketException
        java.lang.IllegalStateException
      • getHostAddrCode

        static long getHostAddrCode()
                             throws java.net.SocketException,
                                    java.lang.IllegalStateException
        Throws:
        java.net.SocketException
        java.lang.IllegalStateException
      • addPortIfMissing

        static java.lang.String addPortIfMissing​(java.lang.String addr,
                                                 int defaultPort)