BufferReader.readline() block PrinterWriter.println()

72 views Asked by At

After creating socket connection in Android App, i can't write in buffer after reading.

This is an example for establishing connection with my Server:

//...
try{    
    socket = new Socket(IP, Port);
    out = new  PrintWriter(new BufferedWriter(
            new OutputStreamWriter(socket.getOutputStream())), true);
    in =new BufferedReader(new InputStreamReader(socket.getInputStream()));
    //ask for connection
    out.println(req1);
    //server send me a nonce
    result=in.readLine().toString();
    //encrypting nonce with specific alghorithm 
    passwd=Password.get_Passwd(result);
    //sending password 
    out.println(passwd); //here out.println doesn't write 
    //...
} catch (IOException e){
    e.printStackTrace();
} finally {
    try {
        socket.close();
        out.close();
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}   
//...

So can any one help me solving this problem. Thanks.

0

There are 0 answers