Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Problem in Java socket reconnection

843790Nov 26 2007 — edited Sep 15 2008
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???

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 11 2008
Added on Nov 26 2007
29 comments
4,775 views