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