使用BufferedWriter的SSLSocket问题

时间:2011-05-21 22:54:20

标签: java android

使用BufferedWriter时发送命令时遇到问题

这是示例

    SSLSocketFactory f = context.getSocketFactory();
    SSLSocket c = (SSLSocket) f.createSocket("198.168.0.10", 8888);
    c.setSoTimeout(20000);
    c.setUseClientMode(true);
    c.startHandshake();

        BufferedWriter w = new BufferedWriter(
           new OutputStreamWriter(c.getOutputStream()));
        Thread.sleep(500);
        w.write("username");
        w.flush();
        Thread.sleep(50);
        w.write("password");
        w.flush();
        Thread.sleep(50);
        w.write("command");
        w.flush();
        Thread.sleep(50);

问题是没有Thread.sleep它不起作用,如果我开始减少50个以上的问题。知道如何解决它,或者使用另一位作家?

0 个答案:

没有答案