We have to loop over `dnsServers` until we meet `null` element to get the correct number of DNS servers:
```
int cnt = 0;
for (InetSocketAddress a: dnsServers) {
  if (a == null) { break; }
  cnt ++;
}
``