When sending a large amount of data in small sections, and frequently calling the write method with a small amount of data, an IOException is thrown stating that the direct Transmission Control Protocol (TCP) connection has timed out, even when the BlackBerry smartphone user remains in a wireless coverage area. Opening a new connection immediately allows data to be sent.
Every time the write method is called on a stream, a BlackBerry smartphone expects a TCP acknowledgement indicating that the destination server has received the data. Sending a large amount of data in very small sections by frequently calling the write method can result in a large number of TCP acknowledgements to be queued on the BlackBerry smartphone. This causes the buffer that queues these acknowledgements to overflow and results in lost TCP acknowledgements. The TCP acknowledgements are not received and the BlackBerry smartphone throws an IOException stating that the connection has timed out.
To resolve this issue, you must lower the frequency of calls to the write method your application makes. The recommended approach is to queue the data within your application and send it in larger sections. There may be cases where this is not possible due to server-side limitations. In these situations you can insert sleep commands within the loop that is calling the write method.
Note: There are other possible causes for this exception, such as a BlackBerry smartphone user moving out of a wireless coverage area.