commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r762023 - /commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
Date Sat, 04 Apr 2009 22:14:58 GMT
Author: rwinston
Date: Sat Apr  4 22:14:58 2009
New Revision: 762023

URL: http://svn.apache.org/viewvc?rev=762023&view=rev
Log:
* Clean up SocketClient.java slightly
* Fix bug where SO_RCVBUF and SO_SNDBUF calls had no effect

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java?rev=762023&r1=762022&r2=762023&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/SocketClient.java
Sat Apr  4 22:14:58 2009
@@ -91,7 +91,13 @@
     /** The socket's connect timeout (0 = infinite timeout) */
     private static final int DEFAULT_CONNECT_TIMEOUT = 0;
     protected int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
-
+    
+    /** Hint for SO_RCVBUF size */
+    int receiveBufferSize = -1;
+    
+    /** Hint for SO_SNDBUF size */
+    int sendBufferSize = -1;
+    
     /**
      * Default constructor for SocketClient.  Initializes
      * _socket_ to null, _timeout_ to 0, _defaultPort to 0,
@@ -151,8 +157,9 @@
     throws SocketException, IOException
     {
         _socket_ = _socketFactory_.createSocket();
+        if (receiveBufferSize != -1) _socket_.setReceiveBufferSize(receiveBufferSize);
+        if (sendBufferSize != -1) _socket_.setSendBufferSize(sendBufferSize);
         _socket_.connect(new InetSocketAddress(host, port), connectTimeout);
-
         _connectAction_();
     }
 
@@ -173,10 +180,7 @@
     public void connect(String hostname, int port)
     throws SocketException, IOException
     {
-        _socket_= _socketFactory_.createSocket();
-        _socket_.connect(new InetSocketAddress(hostname, port), connectTimeout);
-        
-        _connectAction_();
+        connect(InetAddress.getByName(hostname), port);
     }
 
 
@@ -199,10 +203,11 @@
                         InetAddress localAddr, int localPort)
     throws SocketException, IOException
     {
-        _socket_ = _socketFactory_.createSocket();
+        _socket_ = _socketFactory_.createSocket();     
+        if (receiveBufferSize != -1) _socket_.setReceiveBufferSize(receiveBufferSize);
+        if (sendBufferSize != -1) _socket_.setSendBufferSize(sendBufferSize);
         _socket_.bind(new InetSocketAddress(localAddr, localPort));
         _socket_.connect(new InetSocketAddress(host, port), connectTimeout);
-        
         _connectAction_();
     }
 
@@ -227,9 +232,7 @@
                         InetAddress localAddr, int localPort)
     throws SocketException, IOException
     {
-        _socket_ =
-            _socketFactory_.createSocket(hostname, port, localAddr, localPort);
-        _connectAction_();
+       connect(InetAddress.getByName(hostname), port, localAddr, localPort);
     }
 
 
@@ -384,7 +387,7 @@
      * @since 2.0
      */
     public void setSendBufferSize(int size) throws SocketException {
-        _socket_.setSendBufferSize(size);
+        sendBufferSize = size;
     }
     
     
@@ -396,7 +399,7 @@
      * @since 2.0
      */
     public void setReceiveBufferSize(int size) throws SocketException  {
-        _socket_.setReceiveBufferSize(size);
+        receiveBufferSize = size;
     }
 
 



Mime
View raw message