java - Connect wifi hotspot phone error: ENETUNREACH -


i have app, app connect 2 phone using hotspot send/recv file. 1 phone create hotspot (wifi hotspot ), connect hotspot phone using below code:

            msocket = new socket();              try {                  msocket.setreuseaddress(true);                 msocket.bind(null);                 msocket.setperformancepreferences(0, 1, 2);                 msocket.settcpnodelay(true);                 msocket.setsolinger(true, 0);                 msocket.setkeepalive(true);                  msocket.connect(new inetsocketaddress(mconnection.getserveraddress(),                         mconnection.getserverport()), socket_connect_timeout);             //operation here....             } catch (socketexception e) {                 ((hotspotconnection)mconnection).getlocalip();                 logutils.loge(log_tag, "init exception:" + e.tostring());             } catch (ioexception e) {                 logutils.loge(log_tag, "init exception:" + e.tostring());             } 

and got below error:

e/mytestwifithread(18918): init exception:java.net.connectexception:  failed connect /192.168.43.1 (port 9876) after 30000ms:  isconnected failed: enetunreach (network unreachable) 

why can't connect hotspot phone, sure hotspot phone address default 192.168.43.1? because have pinged 192.168.43.1 , hotspot phone replied.

i've encountered problem before. , works me.

change way of communication sockets.

try open server socket on client connects hotspot, , create client socket on tethering device connect server socket.

android connect tethering socket

this might help!!


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -