Questions tagged [inetaddress]

218 questions
2
votes
0 answers

Resolve Ip address from hostname for other devices connected through wifi network android programmatically

From my testing android device i want to get IP address through host name of particular device connected through wife network this below code runs fine in some testing android devices but in other devices its give me UnknownHostException, Why it is…
shyam002
  • 187
  • 1
  • 3
  • 17
2
votes
0 answers

why String got appended with un-printable characters

I want to obtain ip address by using this following classes, and accidentally found out that the ipAddress from the following code sometimes contains un-printable characters such as DC2, CAN...I would like to see if you know what cause this result…
IHC_Applroid
  • 790
  • 8
  • 24
2
votes
1 answer

How to get listening server port in Java?

My application is deployed in websphere server and from java code, I need to get listening port of the server. NOTE: I am using below line for getting internal host name of the system. InetAddress.getLocalHost().getHostName(); EDIT: Our server is…
Tapas Jena
  • 899
  • 4
  • 12
  • 22
2
votes
1 answer

find the network connection type(wired or wireless) by its IP address in java

I want to list all the devices connected to my network, I done like this InetAddress i = InetAddress.getLocalHost(); byte[] ip1 = i.getAddress(); for (int b = 0; b <255;b++) { ip1[3] = (byte)b; InetAddress address =…
2
votes
1 answer

Xamarin INetAddress.GetByName always throws exception

I'm trying to get the INetAddress with the following code: try { var address = InetAddress.GetByName ("google.com"); System.Diagnostics.Debug.WriteLine (address); } catch (Java.Net.UnknownHostException) { System.Diagnostics.Debug.WriteLine…
BisaZ
  • 211
  • 1
  • 2
  • 9
2
votes
2 answers

Occasional error Using InetAddress.getByName()

In my application, I use InetAddress.getByName() quite a bit to convert strings like "192.168.1.56" to InetAddress objects -- mainly because it seems to me to be a good idea to store IP addresses as IP addresses rather than as strings. Up til now,…
Rich
  • 3,849
  • 5
  • 31
  • 45
2
votes
1 answer

Getting Yahoo IP address is not working

I get the Yahoo IP address using InetAddress class in java. The result of yahoo.com IP address is not working while given in URL of web browsers. InetAddress[] all = InetAddress.getAllByName("www.yahoo.com"); for (int i=0; i
Venkat
  • 18,946
  • 25
  • 71
  • 83
2
votes
1 answer

get IP from socket connect from localhost in java

how i get ip of socket conncet from localhost ? i try this : ServerSocket ss = new ServerSocket(1919); Socket test,s = new Socket("127.0.0.1",1919); test=ss.accept(); System.out.println("we connect "); InetAddress…
zdi301
  • 45
  • 2
  • 9
2
votes
1 answer

Return internal IP from NetworkInterface Android

I am using the code to grab the IPv4 address my device is using: public static String getIPAddress(boolean useIPv4) { try { List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for…
Dan James Palmer
  • 2,088
  • 5
  • 36
  • 61
2
votes
1 answer

How to resolve java.net.ConnectException: /ip_address:port - Connection refused exception in android

I am getting java.net.ConnectException: /ip_address:port - Connection refused exception. Here is the code: public boolean sendMessage(String message, String ip, int port) { try { Log.i("Log", "Socket Operator IP before…
Narendra Pal
  • 5,984
  • 10
  • 44
  • 83
2
votes
5 answers

Java InetAddress failed

I am trying to check if some host is reachable using the "isReachable" method. line 113: oaiBaseURL = "http://www.cnn.com";////////////////////////////////////// line 114: boolean res = InetAddress.getByName(oaiBaseURL).isReachable(10000); line 115:…
Mike
  • 899
  • 2
  • 13
  • 31
2
votes
1 answer

How to check if an IP is contained in a network with python?

How do I check whether an IP is contained in a network with python? Eg: # pseudo code IP('10.40.0.1').contained_in(CDIR('10.40.0.0/24)) == True
nemesisdesign
  • 6,832
  • 10
  • 51
  • 90
2
votes
2 answers

Java - How to invoke a IP Address to find host name?

The code I've made automatically returns the host name. But instead of returning my machine's host name every time. I want to checkup on other machines as well (for testing purpose). By that I mean, every time I call the method, it'll ask me to…
Dembele
  • 803
  • 4
  • 10
  • 17
2
votes
4 answers

Android Issue on some devices

I want to use the following code for my application: InetAddress inetAddress; try { inetAddress = InetAddress.getByName(hostname); } catch (UnknownHostException e) { return -1; } It works well on most of the devices I've tested but…
Manitoba
  • 8,172
  • 9
  • 53
  • 110
2
votes
1 answer

How to ping a server from an android tablet

I am trying to write an android tablet application which scans for a set of ip addresses in the local network and check whether they are in use or alive. I am using the InetAddress.getByName(ipAd).isReachable(100) but when i check the logs it…
Mr.Noob
  • 955
  • 3
  • 21
  • 56