Merge pull request #890 from xoofx/master
[mono.git] / mcs / class / System.Runtime.Remoting / System.Runtime.Remoting.Channels.Tcp / TcpClientTransportSink.cs
index e31e286424eceebb7f8925418026a95c7f6cc825..df0f08501bddd3c8a13dacc27262484deb372c26 100644 (file)
@@ -45,7 +45,19 @@ namespace System.Runtime.Remoting.Channels.Tcp
                public TcpClientTransportSink (string url)
                {
                        string objectUri;
-                       _host = TcpChannel.ParseTcpURL (url, out objectUri, out _port);
+                       string port;
+                       
+                       TcpChannel.ParseTcpURL (url, out _host, out port, out objectUri);
+                       
+                       try {
+                               if (port != null)
+                                       _port = Convert.ToInt32 (port);
+                               else
+                                       _port = 0;
+                       } catch {
+                               _host = null;
+                               _port = -1;
+                       }
                }
 
                public IDictionary Properties
@@ -87,7 +99,11 @@ namespace System.Runtime.Remoting.Channels.Tcp
                                if (!isOneWay) 
                                {
                                        sinkStack.Push (this, connection);
-                                       ThreadPool.QueueUserWorkItem (new WaitCallback(ReadAsyncTcpMessage), sinkStack);
+                                       ThreadPool.QueueUserWorkItem (new WaitCallback(data => {
+                                               try {
+                                                       ReadAsyncTcpMessage (data);
+                                               } catch {}
+                                               }), sinkStack);
                                }
                                else
                                        connection.Release();