whyclj
2019-10-19 7472af97a705945ecb45d8baff9f4c2234d4c553
测试连接bug修复
1个文件已修改
11 ■■■■■ 已修改文件
platforms/android/app/src/main/java/com/socket/MySocketClientThread.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
platforms/android/app/src/main/java/com/socket/MySocketClientThread.java
@@ -494,14 +494,23 @@
    //测试当前ip是否可以连接
    public boolean testSockConn(String server_ip){
        boolean flag = false;
        Socket socket1 = null;
        try {
            Socket socket1 = new Socket();
            socket1 = new Socket();
            Log.e(TAG, "testSockConn: "+server_ip );
            SocketAddress socAddress = new InetSocketAddress(server_ip, this.server_port);
            socket1.connect(socAddress, 3000);
            flag = true;
        } catch (IOException e) {
            e.printStackTrace();
        } finally{
           if(socket1 != null){
               try {
                   socket1.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
        }
        return flag;
    }