Questions tagged [inetaddress]
218 questions
3
votes
2 answers
Odd InetAddress.isReachable() issue
My work is developing software for network capable cameras for retail enviroments. One of the peices of software my team is developing is a webserver that retrieves various reports generated in HTML by the camera itself (which has its own embedded…
Jgregoire108
- 109
- 1
- 9
3
votes
1 answer
Multi threaded UDP socket programming in Java
i just designed an application in Java to enable chat between multiple clients using one server. I used UDP sockets and multithreading. I had some questions about that:
Client side code:
private void sendMessage(String s) throws Exception
{
…
previouslyactualname
- 673
- 1
- 10
- 23
3
votes
3 answers
Safe method to get computer IP on UNIX using Java
I need to get computer IP from Ubuntu using Java. I tried with InetAddress.getLocalHost.getHostAddress().toString(); but it returns 127.0.0.1 . I was searching for solution and found out this code:
NetworkInterface ni =…
user2496520
- 831
- 4
- 13
- 32
3
votes
2 answers
Different results between nslookup and Java's InetAddress getHostName
I'm trying to write a simple java program that will return the dns names of ip addresses which I do using the following code:
InetAddress host = InetAddress.getByName(ip);
String dnsName = host.getHostName();
When a dns name is registered…
Vasilis
- 2,362
- 3
- 29
- 48
2
votes
2 answers
Android - comparing two InetAddress which are equal fails?
I have an app that I am now developing multiplayer for. However I do not have 2 phones so I have been running a separate program on my pc (note: not the emulator!) which simulates my program and the multi-player aspects.
However on the PC I have the…
iexus
- 687
- 10
- 25
2
votes
2 answers
IPv6ToBigInteger
I have this function which uses InetAddress, but the output is occasionally wrong. (example: "::ffff:49e7:a9b2" will give an incorrect result.)
def IPv6ToBigInteger(ip: String): BigInteger = {
val i = InetAddress.getByName(ip)
val a:…
Hub
- 23
- 3
2
votes
2 answers
Threads getting into blocked state while doing a host name look up using java.net.InetAddress.getLocalHost
Please find below the application/environment details where the problem is seen.
Java Web application deployed on Tomcat 9.0.35 with JRE Version 1.8.0_231-b11
The application is running in a docker container deployed on Open shift Kubernetes…
Sharath
- 21
- 1
2
votes
1 answer
Java: InetAddress.getLocalHost(); throws java.net.UnknownHostException
Im having a problem running my Java application:
When the following line gets executed, it thows an exception:
InetAddress.getLocalHost();
The following exception gets thrown:
java.net.UnknownHostException: ????????: ????????
at…
smokeSH
- 109
- 2
- 9
2
votes
4 answers
How can I check if a String is IPv4 / IPv6 or domain name? (Java)
How can I check if a string matches a IPv4, IPv6 adress or a domain name like www.google.com?
I found this for IPv4:
Validating IPv4 string in Java
And the same kind of system works for IPv6 but how can I check domain names?
EDIT:
To clarify: I want…
F_Schmidt
- 508
- 3
- 19
2
votes
0 answers
InetAddress.getHostName() does not return expected reverse name lookup from remote IP, like linux Host command
I have a simple java program that will print the dns name of IP address.
package p1;
import java.net.InetAddress;
public class Main {
public static void main(String[] args) throws Exception {
…
cgean
- 21
- 2
2
votes
2 answers
getLocalHost() shows wrong IP address
I am trying to execute following code. I am new to Java, so this is my first time in java.net. There is no error in program, but I am getting localhost address as 192.168.56.1 whereas my IP is 192.168.2.10
import java.net.*;
class InetAddressDemo
{
…
Atharv Kurdukar
- 61
- 2
- 6
2
votes
2 answers
Obtain ISP IP Address Android
Started working on a network monitoring app and I was wondering if there was a way to find out the ISP assigned IP address?
I've looked into the Inet and WifiManager API's and all they seem to give you is your local network ip address. The code I…
Crouch
- 776
- 2
- 15
- 31
2
votes
1 answer
How InetAddress object returns true when it calls isAnyLocalAddress()?
I write a program to check whether a given IP address is Any Local Address or not as:
import java.net.*;
class GetByName
{
public static void main(String[] args) throws Exception
{
byte[] b = {0, 0, 0, 0};
…
my name is GYAN
- 1,139
- 9
- 22
2
votes
0 answers
How to get device's (android)name when we know its Ip address connected under same network?
We got IP addresses of all connected devices under network by using the isReachable() method. (We are checking each IP manually by this method.)
We are intending to get the device name which we assign initially to our android device.
Is there any…
Bond
- 53
- 10
2
votes
1 answer
Comparator adding blank cells to near top of JTable
I have a comparator which takes strings, converts them into InetAddress. However if a string = "" it places the row near the start but after the rows with the value 0:0:0:0:0:0:fff:ffff.
import java.util.Comparator;
import…
Dan
- 5,704
- 4
- 31
- 75