activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1477837 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
Date Tue, 30 Apr 2013 21:22:02 GMT
Author: tabish
Date: Tue Apr 30 21:22:02 2013
New Revision: 1477837

URL: http://svn.apache.org/r1477837
Log:
fix for: https://issues.apache.org/jira/browse/AMQNET-437

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs?rev=1477837&r1=1477836&r2=1477837&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
Tue Apr 30 21:22:02 2013
@@ -94,6 +94,13 @@ namespace Apache.NMS.ActiveMQ.Transport.
             set { sendTimeout = value; }
         }
 
+		private int connectTimeout = 30000;
+		public int ConnectTimeout
+		{
+			get { return connectTimeout; }
+			set { this.connectTimeout = value; }
+		}
+
         #endregion
 
         #region ITransportFactory Members
@@ -253,12 +260,17 @@ namespace Apache.NMS.ActiveMQ.Transport.
 						{
 							DoBind(socket, localAddress, localPort);
 						}
-						
-                        socket.Connect(new IPEndPoint(address, port));
-                        if(socket.Connected)
-                        {
-                            return socket;
-                        }
+
+						IAsyncResult result = socket.BeginConnect(new IPEndPoint(address, port), null, null);
+						result.AsyncWaitHandle.WaitOne(ConnectTimeout, true);
+						if(!socket.Connected)
+						{
+				            socket.Close();
+						}
+						else
+						{
+							return socket;
+						}
                     }
                 }
                 catch



Mime
View raw message