| | |
| | | //测试当前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; |
| | | } |