Connection Timedout can be achieved by 2 ways as per my knowledge.
1)Setting third param in Connector.open(,,boolean timedout) to true.The genearal default timedout is nearly 2-3 minutes.There is no way to override the default timedout value.If there is , please let me know...
Use 2nd way to overcome this.
2)Use a TimerTask ,Close the connection in TimerTask.
Look at the sample code here.
The problem in this method is the connection closing is taking 1 minute additional time for me.In order to overcome this one i closed connection in a separate thread , did my things parallelly so that this time won't effect my code and connection will be closed successfully.This is one of the reasons for separate thread implementation.
And closing connection in a separate thread is a good practice.
Note:Make sure that connection objects and stream objects are not used while closing.
Thank u for the post
ReplyDelete