You need a separate thread for reading.

*Thanks and Regards,
Kumar Bibek*
*
http://techdroid.kbeanie.com
http://www.kbeanie.com*



On Tue, Nov 1, 2011 at 11:09 PM, Tonez <apires...@gmail.com> wrote:

> Hi Everyone,
>
> I have a .net c# application acting as a server listening on a
> particular port, and an Android app that I'm building acting as the
> client which will connect and send / receive tcp messages to / from
> the .net server application.  I have it working at the moment but am
> faced with a challenge that I'm hoping has a better solution than the
> one I've implemented.  My Android app connects to the .net server
> fine, upon successfully connecting the .net application sends back a
> tcp message - my Android app receives this message but it won't
> continue code execution whilst it's reading the connected stream
> unless I close the network stream in the .net server application.
> Below is the bit of code which handles reading / writing to the
> network stream:
>
> out = new PrintWriter( new BufferedWriter( new
> OutputStreamWriter(socketObj.getOutputStream())), true);
> in = new BufferedReader( new
> InputStreamReader( socketObj.getInputStream()));
>
> out.printLn("my command");
>
> String text = "";
> String responseStr = "";
>
> while ((text = in.readLine()) != null) {
> responseStr += text;
> }
>
> So the while loop above continues to execute until I close the network
> stream in the .net app.  Is there some way of specifying to the
> Android / Java network stream that the data being sent has ended so it
> can break out that while loop and continue code execution apart from
> closing down the network stream on the .net side?
>
> Thanks for the help.
>
> T
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to