Questions tagged [inetaddress]

218 questions
4
votes
0 answers

Unable to get Hostname (Computer name) using InetAddress in android

i am working on one module to scan local network and Ip, Mac, Hostname and other details of other devices connected through the same network. i am unable to get Host PC name from InetAddress class in android. Please check my below code: String…
Rl.Android
  • 41
  • 6
4
votes
2 answers

InetAddress java 8 is not getting the hostname

InetAddress.getLocalHost().getHostName() is no more getting the name of the HostName since I switched to java 8 ... with the jdk1.8 the InetAddress.getLocalHost().getHostName() returns "localhost". Before (when I was using jdk1.6) it gives me the…
Mohamed Taboubi
  • 4,885
  • 9
  • 41
  • 76
4
votes
3 answers

How to turn Java class into one of its subclasses (SocketAddress and InetSocketAddress)

I am trying to get the IP of a socket connection in string form. I am using a framework, which returns the SocketAddress of the received message. How can i transform it to InetSocketAddress or InetAddress?
vasion
  • 1,197
  • 3
  • 17
  • 29
4
votes
3 answers

Get hostname from request

I'm running my application on Windows Server 2008 on an Intranet. To login the application tries to get the hostname from the request to validate the user. However, sometimes the application returns the IP address instead of the name and some time…
GoAlves
  • 355
  • 3
  • 4
  • 14
4
votes
3 answers

guava - InetAddress.coerceToInteger returns int instead of long

I have a question about Guava's InetAddress.coerceToInteger method. According to docs the method: public static int coerceToInteger(InetAddress ip) 'Returns an integer representing an IPv4 address regardless of whether the supplied argument is an…
Ido
  • 543
  • 4
  • 11
3
votes
2 answers

How do I access the Connection-specific DNS Suffix for each NetworkInterface in Java?

Is it possible within a Java program to access the string contained in the "Connection-specific DNS Suffix" field of a Windows machine's ipconfig /all output? Eg: C:>ipconfig /all Ethernet adapter Local Area Connection: Connection-specific DNS…
arjunaw
  • 91
  • 1
  • 5
3
votes
1 answer

How to get the DNS resolution time without using the class InetAddress or avoiding the 10 min cached time?

I've been trying to get the DNS resolution time using the next code: val url = URL(dataExperienceTestResult.pingUrl) val host: String = url.host val currentTime: Long = SystemClock.elapsedRealtime() val address: InetAddress =…
3
votes
0 answers

InetAddress.getAllByName() BLOCKED

I encountered a wired question recently. I have an android device which connected the wifi, I'm sure the wifi is fine. but the android device can't access the internet. Then I found something wrong with the DNS resolution, here is what I did. 1. I…
Will Tang
  • 770
  • 1
  • 5
  • 15
3
votes
2 answers

InetAddress.getAddress() always returns a null, but somehow still works

I have a String IP address that I need to convert to a byte array. For this, I used InetAddress.getByName(ip).getAddress(), and it all works great. However, when I looked at the code of InetAddress.getAddress(), it looks like this: public byte[]…
a3y3
  • 691
  • 1
  • 5
  • 24
3
votes
1 answer

a funny thing happens... ExecutorCompletionService

I have an application written in java that needs to find all the reachable hosts on the network. I use InetAddress.isReachable() to do this with a timeout of 2000 milliseconds. I look up the current local machine's IP address and based on that I…
Hector
  • 2,024
  • 15
  • 69
  • 142
3
votes
1 answer

Why does Java InetAddress.isReachable() not work on JRE 1.8.x like on JRE 1.7.x

I've written a programm a year ago and today I saw that this programm give me some curious output. One kind to detect PC's or notebooks in our network I'm using the InetAddress class. My programm works how it should, until Java 1.8.x runs on the…
prototype0815
  • 532
  • 2
  • 6
  • 23
3
votes
2 answers

Why is Java's InetAddress getHostName() not giving me the host's name?

I'm trying to get the device's name using its local IP address on the network. Is this how I'm supposed to do it? ex) Arnold-PC, andoid-nnnnnnnnnn String name = InetAddress.getByName(ip).getHostName(); System.out.println(name); The above should…
God Usopp
  • 337
  • 1
  • 5
  • 14
3
votes
1 answer

ipv4/ipv6 network address match in node-js

I am looking for something like python's netaddr.IPNetwork in node.js. Basically, i have IP network addresses like 1.1.1.1/30, 1::/128 and want to validate in the backend in express if the data provided by user is valid ip network? Thanks,
abarik
  • 2,544
  • 4
  • 39
  • 76
3
votes
4 answers

INetAddress Direct Instantiation

I'm fairly new to Java but not programming and I ran into this: InetAddress localAddress = InetAddress.getLocalHost(); It looked off to me. We're declaring localAddress as type InetAddress but it's being assigned an instance of a static method of…
user3743473
  • 45
  • 1
  • 5
3
votes
1 answer

How can I get domain name in Java

I need domain name. Currently I am getting domain name as follows InetAddress addr; String hostnameCanonical; try{ addr = InetAddress.getByName(InetAddress.getLocalHost().getHostName()); hostnameCanonical = addr.getCanonicalHostName(); …
Sachin
  • 247
  • 3
  • 12
  • 25
1 2
3
14 15