Re: [android-developers] Re: Socket freezes using GSM connection

2010-06-02 Thread Kostya Vasilyev
Ayanir, If the origin of this problem is losing GSM signal, then you've got handle Android specific broadcast actions to detect this. TCP/IP does not detect broken connections if there is no data being sent - i.e. you only find out that the connection is broken when you try to send. This is

[android-developers] Re: Socket freezes using GSM connection

2010-06-02 Thread ayanir
Kostya, I've changed the reading as you suggested and I haven't found any significant improvement although I do think that you proposal is a better programing to avoid problems like connection problem which cause missing packets. I didn't understand if your implementation with NIO give you better

Re: [android-developers] Re: Socket freezes using GSM connection

2010-06-01 Thread Kostya Vasilyev
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

[android-developers] Re: Socket freezes using GSM connection

2010-06-01 Thread 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 wrote: > Ah, so those are data streams. Sorry I missed that (using NIO socket > channels here :) > > Th

Re: [android-developers] Re: Socket freezes using GSM connection

2010-06-01 Thread Kostya Vasilyev
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 no

[android-developers] Re: Socket freezes using GSM connection

2010-06-01 Thread ayanir
Thanks for your replays. 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? Mark, I'll

Re: [android-developers] Re: Socket freezes using GSM connection

2010-05-29 Thread Kostya Vasilyev
Ayanir, Your code seems to make assumptions about network data exchange that don't necessarily hold true for GSM connection, such as: - write() always sending the entire data buffer, this may not be the case. It's necessary to check the return value to see how much was actually sent. - read(

Re: [android-developers] Re: Socket freezes using GSM connection

2010-05-29 Thread Mark Murphy
ayanir wrote: > anyone? There are broadcast Intents for when the data connection changes. You could monitor those and open up a fresh socket. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Bus

[android-developers] Re: Socket freezes using GSM connection

2010-05-29 Thread ayanir
anyone? On May 27, 5:31 pm, ayanir wrote: > Hello, > > I’m working on application that uses a socket connection. > I’ve implemented 2 different Threads for the read() and the write() > methods so they are not being blocked by the read. > Everything is working well on the WiFi connection but when