views:

43

answers:

0

I'm currently trying to write a client-server based application for android (Will be a simple Chat client someady...)

But when Using the local Port at 10.0.2.2 the Client (the Android App) seems to loose the data written into the stream.

It's very strange. The first commands (while handshaiking) arrive and suddenly the Read call on socket returns no results, but the server sends out the data. When accessing the server from remote (Over internet) it just works fine.

Also, very strange is, that the time Read won't return anything, I can successfully write over the socket and the commands arrive at the server

    public synchronized String Read(){
    String result = "";
    if(!CheckInet()){
        Toast.makeText(con, R.string.ConnectionProblems, Toast.LENGTH_LONG).show();
        return null;
    }
    try {
        /*Reads data from Stream*/
        if(rd == null) 
            rd = new BufferedReader(new InputStreamReader(S.getInputStream()));

        if(S.getInputStream().available()==0)return null;
        result = rd.readLine();
    } catch (IOException ex) {
        Toast.makeText(getApplicationContext(), getString(R.string.ReadError), Toast.LENGTH_LONG);
        Disconnect();
    }


    return result;
}

is the Code for reading. Does anyone has a tip? Maybe something simple it's my first java and my first android project. So it may be a thinking-fault also?


No Suggestions? Problem is still remaining. Apk works well while NOT performing over localhost.