real time reading would be if you can read say fixed length by read command you may be able to achieve that say read(100 bytes) and then if you think you are going receive more then continue loop etc
as far as outputting real time you can do thread once u read send it to a thread that takes care of updating textview or other way would be dealing with handler. with handler u just send message to handler and in handler whenever it receives message it updates the ui elements if thats the case but it happens on main ui thread when it is ready to do hence not guaranted real time but this is one of good ways to achive ui updates from a secondary thread. also i heard about asynthread if i am not mistaken. you can try some of these see if something fits ur criteria On Tue, Mar 2, 2010 at 6:31 PM, Mike Mackintosh <[email protected]> wrote: > Looking to see if anyone knows how to read a socket and output the data > realtime. Above, it waits for the while to end, which defeats the purpose of > listening. > > On Mar 1, 2010 3:33 AM, "#iNjection-" <[email protected]> wrote: > > I have a mini app i use to connect to a TCP listener script. The > problem i am having is taht when a message is received by the listener > script, it will send it to all open sockets currently connected. > > Within the Android app, i have a line where i am doing the following: > > > while((responseLine = is.readLine()) != null) > { > Toast.makeText(context, responseLine, > Toast.LENGTH_LONG).show(); > > if (responseLine.indexOf("Ok") != -1) { > break; > } > } > > is.readLine() is the resource returns by DataInputStream. Now, my > Listener is set to send a message of Ok if no input has been sent > within 30 seconds, so of course, it will break the while. But it is at > this point, all messages from the other sockets are displayed via > Toast or TextView if I implement that. > > Does anyone know of a way to flush Toast or TextView while inside of > an indefinite While loop? I know the incoming messages are being > appended to the buffer, but can't output until the while is killed? > > > Thanks! > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

