• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps android socket read/write client help!

wenn32

Lurker
hello guys i have been trying to read and write data to socket buffer i even looked into example but went in vain
here is my code (only client)


Code:
try {

        FTPSocket = new Socket("209.85.149.105",80);//google.com
    } catch (Exception e) {

        return false;
    }


    try {
            buf_in = new BufferedReader(new InputStreamReader(FTPSocket.getInputStream()));

            buf_out = new BufferedWriter(new OutputStreamWriter(FTPSocket.getOutputStream()));
        } catch (Exception e) {

            return false;
        }

    try{

        buf_out.write(send,0,send.length());//send is string with "Hi"
    } catch (Exception e) {

        return false;
    }

    try{

        buf_in.read(read,0,1000);//read variable is a char[]


    }catch (Exception e) {

        return false;
    }


i tried to change
buf_in.read(read,0,1000); to buf_in.read(read,0,5000);
i getting an exception at the buf_in.read().please help me i am stuck


Thanks!
 
it throws an exception in this part

Code:
try{
   buf_in.read(read,0,1000);//read variable is a char[]
}catch (Exception e) {
   return false;
}

i checked whether it was indexoutofbounds or IO exception but it was neither of these.what could be the problem in this TCP model
 
Back
Top Bottom