I am trying to connect to a local network server using hostname (you can not use IP because the client network does not allow fixed ip and the device does not have IP backup per MAC).
So, I'm trying to do this from an Android application, so far I've been able to get the IP from the hostname but since there is more than one network card on the machine, IPs.
The code that is returning me an IP is as follows: (in asyncTask)
ArrayList <String> lista = new ArrayList<String>();
try
{
InetAddress ipaddress = InetAddress.getByName(hostname);
lista.add(ipaddress.getHostAddress());
}
catch (UnknownHostException e)
{
lista.add("Ip não encontrado para o hostname: "+ hostname);
}
return lista;