When Wifi disconnect, how does Socket on Android server side know that?
I developed an Android app, which works in Wifi AP mode as a Socket server. Some clients setup Wifi connection and socket connection with my app. When the socket is connected, I disconnect the Wifi connection from the client, however there is no exception nor the read method of socket return -1 in my server app. My questions are:
Thanks.
在线程中使用它
public static boolean checkNetworkConnection(Context context)   
{   
   final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);   
   final android.net.NetworkInfo wifi =connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);   
   final android.net.NetworkInfo mobile =connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);   
   if(wifi.isAvailable()||mobile.isAvailable())   
       return true;   
   else  
       return false;   
}  
上一篇: 多约束背包问题
