Questions tagged [inetaddress]
227 questions
1
vote
1 answer
InetAddress get IP inconsistency
I'm trying to go through a list of URL's and grab their IP but what I'm noticing is sometimes it will get hung up on a website and never move on and other times it will skip a bunch of websites. Does anyone know what's causing this?
for (String site…

cantread
- 405
- 1
- 7
- 14
1
vote
0 answers
InetAddress.getByName() failing for hostnames without suffix
I added a static DNS entry into my router, binding some IP address to builds-mac. I then attempted to look up its IP address using Java:
import java.net.InetAddress;
import java.net.UnknownHostException;
public class Testcase
{
public static…

Gili
- 86,244
- 97
- 390
- 689
1
vote
1 answer
I am trying to ping www.google.com using JAVA in my office but it is not pinging the same
I am trying to ping www.google.com in my office network but it is not pinging. Code which i am using is as follows:
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class demo1 {
public…

user3309461
- 11
- 1
- 2
1
vote
4 answers
Why the ip address value is and with int 255
I have a simple program to find my IP address and convert it to a String.
Why is the b[i] value with (int)255 below?
public class FirstSocketProgramming {
public static void main (String arg[]){
InetAddress local = null;
try {
…

CtrlV
- 115
- 11
1
vote
1 answer
Java Inetaddress getallbyname error
I am using Java InetAddress to find if the current internet connection can resolve an address via DNS. However if I put in a random address (One that definitely dose not exist on the internet) I still get an IP back, can anyone explain why this is…

user2568364
- 11
- 1
1
vote
0 answers
Android - getHostName() returns app name?
In the android app I am working on, I am simply trying to get host names corresponding to ip addresses.
private class hostLookUp extends AsyncTask{
protected String doInBackground (InetAddress...ip){
int…

user2544738
- 46
- 6
1
vote
1 answer
Safe Java Pinging
I have a project that pings all computera on LAN network. First I used InetAddress.isReachable() but sometimes function returns that IP is not reachable() even if IP is reachable(tried with build in function on windows and IP was reachable) . Second…

ZhiZha
- 143
- 2
- 4
- 13
1
vote
2 answers
Using InetAddress to get own IP
I have an issue were if I try to InetAddress.getLocalHost() or even InetAddress.getByName(String host) it throws an exception every time even for a known website like nba.com I am a bit confused FYI the target device is an android 4.1.1 GS3 and wifi…

frank johnson
- 153
- 2
- 9
1
vote
2 answers
Java - Throwing an exception if user entered invalid IP address or host name
I want to throw an exception that when a user enters an invalid IP address, host name or not a fully qualified domain name it'll bring up an error message.
I'm not too sure whether to use unknownhostexception or IOException.
I tried doing if…

Ajay Punja
- 101
- 4
- 11
1
vote
1 answer
Error when using isReachable() in Android
I am a newbie in android development. This is my code
boolean isReachable = false;
try{
isReachable = InetAddress.getByName(MyIPAddress).isReachable(reachableTimeout);
} catch (Exception e){
Log.e("InetAddress", e.getMessage());
}finally {
…

jnsn
- 13
- 1
- 8
1
vote
1 answer
Unable to resolve host Android
I want to send a http request from my Android device using a local proxy.
Before to detail my problem, I want you to know this is working well on every device I tried except on the Xperia arc S, and Xperia T, both running under Android 4.0.4. I do…

Manitoba
- 8,522
- 11
- 60
- 122
1
vote
2 answers
android ping InetAddress and editText
I want to input an ip in an EditText box,
then give the result in a textView via button ping ( reachable or not)
public class MainActivity extends Activity {
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
…

user1814662
- 281
- 1
- 3
- 5
1
vote
1 answer
Current connection info - Java
I am trying to get my program display what the ipconfig command displays in windows. I have managed to get the hostname and the IPv4 address, how can I get IPv6 address and subnet mask? I have tried various things to no avail so far. My code is:
try…

Angelos Chalaris
- 6,611
- 8
- 49
- 75
1
vote
2 answers
IP Address in Java on Linux
So far I always used following to get my IP Address:
InetAddress.getLocalHost().getHostAddress()
The above method works for Windows but on linux I always get 127.0.1.1 as my IP address.
What am I doing wrong?
user1231969
0
votes
1 answer
How can I catch the exception if IPV6 address is passed
This is my below code and I want to catch the exception if any IPV6 address is passed. Any idea how it can be done in my code?
private static boolean validateAnIpAddress(String ipAddr) {
InetAddress address = null;
boolean isIPv4;
…

arsenal
- 23,366
- 85
- 225
- 331