Android Socket Error-> libcore.io.IoBridge.connect(Iobridge.java.114)

时间:2014-07-21 12:15:08

标签: java android sockets socket.io

在下面的代码中,我只是创建一个套接字来在我的应用程序中运行Shell命令,但问题有时会运行并且大部分时间它都会通过错误( libcore.io.IoBridge

PrintWriter writer = null;
        BufferedReader in = null;
        String inputLine;
        try {
            Socket clientSocket = null;

            clientSocket = new Socket(LOCAL_ADDRESS, PORT);

            Log.d("ExecuteService", (clientSocket.isConnected() ? "Connected" : "Not Connected"));

            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream())),true);
            writer.println(cmd);
            writer.flush();
            Log.d("ExecuteService", "Lineis in:" + cmd);
            in = new BufferedReader(new InputStreamReader(
                    clientSocket.getInputStream()));

            while ((inputLine = in.readLine()) != null) {
                Log.d("ExecuteService", "Lines :" + inputLine);
            }

            Log.d("ExecuteService", "Lineis out:" + cmd);

            writer.close();
            writer = null;
            in.close();
            in = null;
            clientSocket.close();
            clientSocket = null;

        } catch (Exception exception) {
            for(StackTraceElement st : exception.getStackTrace())
                Log.d("ExecuteService", st.toString());
        }

    }

任何人都可以告诉我这个错误发生时的情况如何?

0 个答案:

没有答案