UPDATE: The hotspot created on oreo and below has static IP which is 192.168.43.1. This is a change in Android 9 and above. and i want to do it for Android 9. I need to run ServerSocket on a static IP address. My scenario is that i need to access my Server which is running on an Android and the server android device has its own WifiHotSpot without internet connectivity. The clients will be connected to the server only when they are connected to that hotspot. I cant seem to find a way to communicate my SERVERSOCKET IP address to the clients as i cant display it on the screen(The screen won't be visible to the user- Special USE CASE). Thats why i need a static IP to run ServerSocket but can't seem to run it as if i give it any IP lets say 192.168.43.180 it gives exception EADDRESSNOTAVAIL address not available. Any help is much appreciated.
SocketAddress socketAddress = new InetSocketAddress("192.168.43.128",2041);
httpServerSocket = new ServerSocket();
httpServerSocket.bind(socketAddress);