try { WifiManager wifiManager = ((ChatActivity)context).getWifiManager(); InetAddress address = InetAddress.getByAddress( ByteBuffer.allocate(4).putInt( Integer.reverseBytes(wifiManager.getConnectionInfo().getIpAddress()) ).array() ); String name = address.getHostName(); Log.i(Constants.TAG, "address = " + address + " name = " + name); jmDns = JmDNS.create(address, name); } catch (IOException ioException) { Log.e(Constants.TAG, "An exception has occurred: " + ioException.getMessage()); if (Constants.DEBUG) { ioException.printStackTrace(); } }