[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...
Ron Sigal
ron_sigal at yahoo.com
Sun Mar 11 16:51:08 EDT 2007
User: rsigal
Date: 07/03/11 16:51:08
Modified: src/main/org/jboss/remoting/transport/socket
SocketClientInvoker.java
Log:
JBREM-598, JBREM-657: Added timeout parameter to createSocket().
Revision Changes Path
1.41 +21 -5 JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SocketClientInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- SocketClientInvoker.java 3 Feb 2007 05:18:46 -0000 1.40
+++ SocketClientInvoker.java 11 Mar 2007 20:51:08 -0000 1.41
@@ -31,6 +31,7 @@
import java.lang.reflect.Constructor;
import java.net.Socket;
import java.net.SocketTimeoutException;
+import java.net.InetSocketAddress;
import java.rmi.MarshalException;
import java.util.Map;
@@ -40,7 +41,7 @@
*
* @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
* @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
- * @version $Revision: 1.40 $
+ * @version $Revision: 1.41 $
*/
public class SocketClientInvoker extends MicroSocketClientInvoker
{
@@ -160,17 +161,32 @@
}
- protected Socket createSocket(String address, int port) throws IOException
+ protected Socket createSocket(String address, int port, int timeout) throws IOException
{
+ Socket s = null;
SocketFactory socketFactory = getSocketFactory();
if (socketFactory != null)
{
- return socketFactory.createSocket(address, port);
+ s = socketFactory.createSocket();
}
else
{
- return new Socket(address, port);
+ s = new Socket();
}
+
+ s.setReuseAddress(getReuseAddress());
+ InetSocketAddress inetAddr = new InetSocketAddress(address, port);
+
+ if (timeout < 0)
+ {
+ timeout = getTimeout();
+ if (timeout < 0)
+ timeout = 0;
+ }
+
+ s.connect(inetAddr, timeout);
+
+ return s;
}
protected SocketWrapper getPooledConnection()
@@ -243,7 +259,7 @@
public String toString()
{
- return "SocketClientInvoker[" + Integer.toHexString(hashCode()) + ", " +
+ return "SocketClientInvoker[" + Integer.toHexString(System.identityHashCode(this)) + ", " +
locator.getProtocol() + "://" + locator.getHost() + ":" + locator.getPort() + "]";
}
}
More information about the jboss-cvs-commits
mailing list