Java Quickly check for network connection

前端 未结 4 1948
暗喜
暗喜 2021-02-20 08:14

My issue is fairly straightforward. My program requires immediate notification if a network connection is lost. I\'m using Java 5, so I\'m unable to use the very handy feature

4条回答
  •  孤独总比滥情好
    2021-02-20 08:35

    Did you try by issuing a DNS resolve?

    You can try with:

    public static InetAddress[] getAllByName(String host)
    

    but I'm unsure if this will require the timeout too..

提交回复
热议问题