[jboss-remoting-commits] JBoss Remoting SVN: r3537 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Fri Feb 29 03:21:21 EST 2008


Author: ron.sigal at jboss.com
Date: 2008-02-29 03:21:21 -0500 (Fri, 29 Feb 2008)
New Revision: 3537

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
Log:
JBREM-703: Added configuration for remaining socket parameters.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java	2008-02-29 04:04:36 UTC (rev 3536)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java	2008-02-29 08:21:21 UTC (rev 3537)
@@ -222,6 +222,20 @@
     */
    protected ServerAddress address;
    protected Home home;
+   
+   /**
+    * Socket configuration parameters.
+    */
+   protected boolean keepAlive;
+   protected boolean keepAliveSet;
+   protected boolean oOBInline;
+   protected boolean oOBInlineSet;
+   protected int receiveBufferSize = - 1;
+   protected int sendBufferSize = -1;
+   protected boolean soLinger;
+   protected boolean soLingerSet;
+   protected int soLingerDuration = -1;
+   protected int trafficClass = -1;
 
    // Constructors ---------------------------------------------------------------------------------
 
@@ -287,6 +301,79 @@
       reuseAddress = reuse;
    }
 
+   public boolean isKeepAlive()
+   {
+      return keepAlive;
+   }
+
+   public void setKeepAlive(boolean keepAlive)
+   {
+      this.keepAlive = keepAlive;
+      keepAliveSet = true;
+   }
+
+   public boolean isOOBInline()
+   {
+      return oOBInline;
+   }
+
+   public void setOOBInline(boolean inline)
+   {
+      oOBInline = inline;
+      oOBInlineSet = true;
+   }
+
+   public int getReceiveBufferSize()
+   {
+      return receiveBufferSize;
+   }
+
+   public void setReceiveBufferSize(int receiveBufferSize)
+   {
+      this.receiveBufferSize = receiveBufferSize;
+   }
+
+   public int getSendBufferSize()
+   {
+      return sendBufferSize;
+   }
+
+   public void setSendBufferSize(int sendBufferSize)
+   {
+      this.sendBufferSize = sendBufferSize;
+   }
+
+   public boolean isSoLinger()
+   {
+      return soLinger;
+   }
+   
+   public int getSoLingerDuration()
+   {
+      return soLingerDuration;
+   }
+
+   public void setSoLinger(boolean soLinger)
+   {
+      this.soLinger = soLinger;
+      soLingerSet = true;
+   }
+
+   public void setSoLingerDuration(int soLingerDuration)
+   {
+      this.soLingerDuration = soLingerDuration;
+   }
+
+   public int getTrafficClass()
+   {
+      return trafficClass;
+   }
+
+   public void setTrafficClass(int trafficClass)
+   {
+      this.trafficClass = trafficClass;
+   }
+
    public synchronized void disconnect()
    {
       log.debug(this + " disconnecting ...");
@@ -1010,11 +1097,24 @@
    protected Socket createSocket(String address, int port, int timeout) throws IOException
    {
       Socket s = new Socket();
-      s.setReuseAddress(getReuseAddress());
+      configureSocket(s);
       InetSocketAddress inetAddr = new InetSocketAddress(address, port);
       s.connect(inetAddr);
       return s;
    }
+   
+   protected void configureSocket(Socket s) throws SocketException
+   {
+      s.setReuseAddress(getReuseAddress());
+      
+      if (keepAliveSet)           s.setKeepAlive(keepAlive);
+      if (oOBInlineSet)           s.setOOBInline(oOBInline);
+      if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
+      if (sendBufferSize > -1)    s.setSendBufferSize(sendBufferSize);
+      if (soLingerSet && 
+            soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
+      if (trafficClass > -1)      s.setTrafficClass(trafficClass);
+   }
 
    protected SocketWrapper getPooledConnection()
    {




More information about the jboss-remoting-commits mailing list