Questions tagged [inetaddress]

218 questions
6
votes
2 answers

Fully qualified machine name Java with /etc/hosts

I am trying get the fully qualified name of my machine (Windows 7 x64) in Java. On my machine, I've updated the c:\Windows\system32\drivers\etc\hosts file such that it has an entry like this: 10.44.2.167 myserver myserver.domain.com All our systems…
Shreyas Shinde
  • 61
  • 1
  • 1
  • 3
6
votes
2 answers

Trying to get network device names with reverse dns in Android

I can able to fetch all device ip addresses in Local Area Network with inetaddress class. What I need to do is reverse lookup ip-address and find as device name in network like : "Jimmie's Macbook" My Code block which able to fetch all IP address…
Onder OZCAN
  • 1,496
  • 1
  • 16
  • 33
6
votes
3 answers

Java application wanting to use both Inet4Address and Inet6Address at the same time

I have a Java application that needs to connect via sockets to two different servers on two separate machines. One server has been configured to listen on IPv4 connections, while the other has been configured to listen on IPv6 connections. Now,…
His
  • 5,412
  • 13
  • 50
  • 73
6
votes
1 answer

Getting the ip address of eth0 interface in java only return IPv6 address and not IPv4

I wrote the following code to get the IPv4 address of the eth0 interface I am using on a machine. However the code only finds fe80:x:x:x:xxx:xxxx:xxxx:xxxx which is not returned since I am looking for the IPv4 address. Here is the code. …
jgr208
  • 2,382
  • 7
  • 29
  • 53
5
votes
2 answers

isReachable in Java doesn't appear to be working quite the way it's supposed to

I'm using Clojure, but I can read Java, so this isn't a Clojure specific question. This doesn't even seem to be working from Java. I'm trying to implement a bit of a 'ping' function using isReachable. The code I'm using is this: (.isReachable…
Rayne
  • 28,305
  • 16
  • 83
  • 100
5
votes
1 answer

Get the smallest network given a list of IPv4 addreses in Python

I am using python 2.6.6 and I am not allowed to change it. I have a sorted list of IPv4 addresses. I need to find the smallest network that covers all the ip addresses in the list. The smallest network can be the CIDR, or a Network address with…
The Governor
  • 1,022
  • 1
  • 11
  • 26
5
votes
1 answer

Can I filter and select only IPV4 adresses on the InetAddress object? How to exlude the IPV6?

I have the following problem: I create an ArrayList and I put in this arraylist all the IP addresses of my client (one if the client have a single network card, n if the client run on a PC having n network card) excluding the loopback adress, the…
AndreaNobili
  • 34,200
  • 85
  • 240
  • 456
5
votes
2 answers

Converting IPV4 Address from bytes to String

I currently am trying to create a chat server as an assignment and want each message to contain a header. It will contain ipv4 address followed by a letter then a username I can easily decode string letters from bytes but now I am struggling to…
5
votes
3 answers

Java. InetAddress.getLocalHost returns strange IP

I'm don't understand, why code below prints 0.0.9.229 instead 127.0.0.1. Can anybody tell me, hot to fix that? String ha = InetAddress.getLocalHost().getHostAddress(); System.out.println(ha); UPD: Code running on Ubuntu /etc/hosts 127.0.0.1 …
shurik2533
  • 1,730
  • 4
  • 22
  • 39
5
votes
0 answers

Java: Intermittent UnknownHostException

In my application which runs on Jboss server, we make an http connection to another application. Both the application lives in the same datacenter. We use the VIP to connect to the application. This works fine in production except for a very small…
user1270392
  • 2,401
  • 4
  • 19
  • 24
5
votes
4 answers

How to get the IP prefix while we have subnet and IPv4 address using python-netaddr?

I am using python-netaddr library to work on IP Addresses and subnets. I read the full documentaion of netaddrd given: Netaddr documentation. But didn't found any solution to my problem. I have a IP Address and subnet i want to get prefix for that…
Amit Pal
  • 9,143
  • 23
  • 64
  • 141
5
votes
3 answers

Java InetAddress.getHostName() taking a very long time to execute

I have the following little code snippet: InetAddress address = InetAddress.getByName(host); if(address.isReachable(TIMEOUT_IN_MILLISECONDS)) { System.out.println(host + " is reachable."); String hostName =…
czchlong
  • 2,294
  • 10
  • 45
  • 61
4
votes
7 answers

how to get the next ip address from a given ip in java?

Folks, Am looking for a Java code snippet, which gives the next address from the given IP. so getNextIPV4Address("10.1.1.1") returns "10.1.1.2". String crunching can be done but might end up messy. Is there a much formalized way for doing…
Rajan
  • 616
  • 3
  • 8
  • 18
4
votes
2 answers

InetAddress getLocalHost() does not return expected IP address from C:\WINDOWS\system32\drivers\etc\hosts

In the file C:\WINDOWS\system32\drivers\etc\hosts I have only the following line 192.168.0.23 computername.domain.com computername When I run InetAddress localhost = InetAddress.getLocalHost(); System.out.println("getLocalHost:" +…
Lars Andren
  • 8,165
  • 6
  • 34
  • 52
4
votes
1 answer

Find IP of program trying to connect to ServerSocket

Although I searched about it I couldn't find an answer. Let's say I have the following Java code: ServerSocket serve = null; try { server = new ServerSocket(5567); } catch (IOException e) { System.err.println("Problem…
Navorkos
  • 43
  • 1
  • 3
1
2
3
14 15