// Lluis Sanchez Gual (lluis@ideary.com)
//
// 2002 (C) Copyright, Ximian, Inc.
-//\r
+//
//
// Permission is hereby granted, free of charge, to any person obtaining
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-\r
-using System;\r
-using System.Runtime.Remoting.Channels;\r
-using System.Runtime.Remoting.Messaging;\r
-using System.Collections;\r
-using System.IO;\r
-using System.Threading;\r
-\r
-namespace System.Runtime.Remoting.Channels.Tcp\r
-{\r
+
+using System;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Messaging;
+using System.Collections;
+using System.IO;
+using System.Threading;
+
+namespace System.Runtime.Remoting.Channels.Tcp
+{
internal class TcpClientTransportSink : IClientChannelSink
{
string _host;
- string _url;
int _port;
public TcpClientTransportSink (string url)
{
string objectUri;
- _host = TcpChannel.ParseTcpURL (url, out objectUri, out _port);
- _url = url;
+ 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
{
- get \r
+ get
{
return null;
}
public IClientChannelSink NextChannelSink
{
- get \r
+ get
{
// we are the last one
return null;
// response of the server
connection = TcpConnectionPool.GetConnection (_host, _port);
- TcpMessageIO.SendMessageStream (connection.Stream, requestStream, headers, connection.Buffer);
+ TcpMessageIO.SendMessageStream (connection.Stream, requestStream, headers, connection.Buffer, isOneWay);
connection.Stream.Flush ();
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();
}
-\r
-}\r
+
+}