Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
New Developer
Posts: 29
Registered: ‎07-28-2008
My Device: Not Specified

Re: READ_TIMEOUT doesn't work

The problem has been further analyzed and the cause has been clearly identified.

 

The nature of the problem can be summarized as follows:

 

InputStreamReader is totally broken when used with a SocketComnection. Although setting READ_TIMEOUT does appear to produce a partially working implementation it is still broken.  When a timeout does occur an IOException results with the message "TCP read timed out" and there is absolutely no way to resume read() on the stream.  But without setting READ_TIMEOUT incoming data totally stops after delivering a couple of hundred bytes.  Tested on 8708g and 9000.

 

By contrast, DataInputStream works perfectly.

 

On other phones using different Java VM implementations, both DataInputStream and InputStreamReader work perfectly on SocketConnection's.  I have tested at least 12 different handsets from different manufacturers (Sony, Morotola, LG, Nokia, Samsung, HTC, etc). Only on RIM's BlackBerry platform is InputStreamReader totally broken.  This includes sdk versions 4.2.1 through 4.5.0 but it is most likely a problem with device system software/java vm.

 

I don't quite understand how Sun could allow BlackBerry to implement such a broken InputStreamReader because it only helps give Sun's product a bad name.  And I am even more amazed that this problem has existed for so long.

 

I am not impressed with the quality of advice on this forum either.

 

New Developer
Posts: 5
Registered: ‎10-21-2008
My Device: Not Specified

Re: READ_TIMEOUT doesn't work

Thank you bb9 for pointing out that the InputStream does not work with socket connection but DataInputStream does.

I replaced the InputStream with DataInputStream in my source code and it works!  I have been trying to figure out this strange behaviour that I am encountering for a long time -- When I loaded the same app cods to the 9000 simulator (running on v4.6.0.92 (Platform)) , I get a connection closed exception, however it runs perfectly fine using the same cods on the real 9000 device(running on v4.6.0.162(Platform 4.0.0.155)).