Ayanir,

NIO is non-blocking, so it's easier to serve multiple connections from one thread. Also, NIO is easier to interrupt / shutdown, which I think is important for an Android app. But other than that, I personally think it's a matter of taste, since there has to be a worker thread for both NIO and "old style".

In the code you posted, DataOutputStream should write the entire data structure, blocking until it does. So with the change on the reading side (looking for '\0' anywhere) it _should_ already work - have you tested it yet?

-- Kostya

01.06.2010 17:53, ayanir пишет:
is the NIO works better then the usual Socket?
by works better I mean no freezing.
I have no problem working with NIO if it will make the difference.

ayanir

On Jun 1, 10:55 am, Kostya Vasilyev<kmans...@gmail.com>  wrote:
Ah, so those are data streams. Sorry I missed that (using NIO socket
channels here :)

Then you should be ok with packet fragmentation - as long as your read
method checks for '\0' anywhere within the buffer.

-- Kostya

01.06.2010 11:43, ayanir пишет:

Kostya, I did as you suggested and I'm now looking for the delimiter
('\0') on the of the last read buffer and not just the last byte.
I didn't understand how can I check the return value in the write()
method since it is declared as void. is there another way?
--
Kostya Vasilev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com


--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
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