inetaddress

    3熱度

    1回答

    關於此link使用提供的代碼來生成IP地址。 String ip; try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterf

    0熱度

    1回答

    我在我的Android工作室(MacOSX的)一個問題: 在InetAddress.java一些進口有問題 import sun.net.util.IPAddressUtil; import android.system.GaiException; import android.system.StructAddrinfo; import libcore.io.Libcore; 編輯

    0熱度

    2回答

    我試圖執行以下代碼。我是Java新手,所以這是我第一次在java.net中。有一個在程序中沒有錯誤,但我得到本地主機地址192.168.56.1作爲我的,而IP是192.168.2.10 import java.net.*; class InetAddressDemo { public static void main(String[] args) { try

    -1熱度

    1回答

    這可能是顯而易見的,但我錯過了它。爲什麼我需要用0xff執行AND來獲取IP地址?我看到它的方式是完全一樣的,用0xff執行AND應該保持相同的位,所以爲什麼不工作,如果我不做AND操作? package com.inet.ex1; import java.net.InetAddress; import java.net.UnknownHostException; public clas

    0熱度

    1回答

    我正在實現一個獲取android設備主機名的方法。我爲此使用InetAddress類。不過,我得到致命的異常。這是方法。我添加了一個try/catch塊,但仍然無法工作。任何幫助讚賞。編輯和添加的異常錯誤 /** * getHostname returns the hostname of android device as string * * @param cont

    0熱度

    1回答

    請幫助我們。我結束了一項簡單程序的工作。我需要檢查服務器狀態。我試圖使用InetAdress.isReacheble和Socket。但有時如果服務器在Windows上,我的服務器狀態爲false。在閱讀了大量信息後,我意識到這是java enter link description here的一個bug。但來源很古老。這個問題仍然相關嗎? 我嘗試使用這個代碼註釋enter link descrip

    0熱度

    1回答

    out.print("ip : "+request.getRemoteHost()); InetAddress ip= InetAddress.getByName(""+request.getRemoteHost()); String host=ip.getHostName(); InetAddress host1=ip; out.print("

    0熱度

    1回答

    我寫一個程序來檢查一個給定的IP地址是否是任何本地地址或不作爲: import java.net.*; class GetByName { public static void main(String[] args) throws Exception { byte[] b = {0, 0, 0, 0}; String s = "abc";

    1熱度

    1回答

    我有isReachable方法InetAddress類有奇怪的行爲。 Method prototype是: public boolean isReachable(int timeout) 當使用超時> 1500(毫秒),該方法等待給定的作爲參數的確切時間 (如果目標IP是不可達當然.. )。 當使用超時< 1500,該方法等待1000ms的最大... 的代碼非常簡單: InetAddress

    1熱度

    1回答

    我寫一個Java程序,讓我的網絡中的所有IP地址 一切都在朝好的方向使用此代碼 InetAddress localhost = InetAddress.getLocalHost(); byte[] ip = localhost.getAddress(); for (int i = 1; i <= 254; i++) { ip[3] = (byte)i; InetAddr