While writing to the socket if IOException occurred I am trying to reconnect to the destination. In reconnection I am trying the following things:
1. After connection drop out for the first time, I am closing the connection
connObj.close();
connObj = null; (for safety purpose trying to make sure that connection object is completely destroyed and candidate of GC now.)
2. Create a new connection object
connObj = new Socket();
connObj.connect(new InetSocketAddress(host, port));
connObj.setReuseAddress(true);
in case again failure occurred while connecting to host and port I am waiting for 5 mins to again reconnect, but with totally new connection object.
But here the problem is it is taking long time to connect on an average 60 minutes.
Can we reduce this time? Is there any other setting in java sockets???