My Android program has to scan 255 LAN addresses to find if an OData service (WCF Data Service) is available.
The service runs on 1 or 2 computers, there are about 20 devices on the LAN but when my code "scans" an IP address that is in use BUT not hosting the service it doesn't throw exception immediatley instead it waits for a long time so finding 2 addresses took 10 minutes.
Here is the code:
try
{
String url = String.format("http://%s/InformationService/InformationService.svc/", ip);
ODataConsumer consumer = ODataJerseyConsumer.create(url);
Enumerable<OObject> result= consumer.callFunction("CheckInformation")
.execute();
Log.i("DEBUG", "Service available: " + ip);
}
catch (Throwable e)
{
//e.printStackTrace();
Log.i("DEBUG", "No service: " + ip);
}
Why does it wait at the reserved IPs if the service is not hosted there?
How can I detect immediately if there is no service there?