public ITransport CreateTransport(Uri location) { // Extract query parameters from broker Uri System.Collections.Specialized.StringDictionary map = URISupport.ParseQuery(location.Query); // Set transport. properties on this (the factory) URISupport.SetProperties(this, map, "transport."); // Console.WriteLine("Opening socket to: " + host + " on port: " + port); Socket socket = Connect(location.Host, location.Port); IWireFormat wireformat = CreateWireFormat(location, map); TcpTransport tcpTransport = new TcpTransport(socket, wireformat); wireformat.Transport = tcpTransport; ITransport rc = tcpTransport; if (UseLogging) { rc = new LoggingTransport(rc); } if (wireformat is OpenWireFormat) { rc = new WireFormatNegotiator(rc, (OpenWireFormat)wireformat); } rc = new MutexTransport(rc); rc = new ResponseCorrelator(rc); return(rc); }
public ITransport CompositeConnect(Uri location) { // Extract query parameters from broker Uri StringDictionary map = URISupport.ParseQuery(location.Query); // Set transport. properties on this (the factory) URISupport.SetProperties(this, map, "transport."); // See if there is a local address and port specified string localAddress = null; int localPort = -1; if (!String.IsNullOrEmpty(location.AbsolutePath) && !location.AbsolutePath.Equals("/")) { int index = location.AbsolutePath.IndexOf(':'); try { localPort = Int16.Parse(location.AbsolutePath.Substring(index + 1)); localAddress = location.AbsolutePath.Substring(1, index - 1); Tracer.DebugFormat("Binding Socket to {0} on port: {1}", localAddress, localPort); } catch { Tracer.Warn("Invalid Port value on URI for local bind option, ignoring."); } } Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port); Socket socket = DoConnect(location.Host, location.Port, localAddress, localPort); #if !NETCF socket.ReceiveBufferSize = ReceiveBufferSize; socket.SendBufferSize = SendBufferSize; socket.ReceiveTimeout = ReceiveTimeout; socket.SendTimeout = SendTimeout; #endif OpenWireFormat wireformat = new OpenWireFormat(); // Set wireformat. properties on the wireformat owned by the tcpTransport URISupport.SetProperties(wireformat.PreferredWireFormatInfo, map, "wireFormat."); ITransport transport = DoCreateTransport(location, socket, wireformat); wireformat.Transport = transport; if (UseLogging) { transport = new LoggingTransport(transport); } if (UseInactivityMonitor) { transport = new InactivityMonitor(transport); } transport = new WireFormatNegotiator(transport, wireformat); return(transport); }
public ITransport CompositeConnect(Uri location, SetTransport setTransport) { // Extract query parameters from broker Uri StringDictionary map = URISupport.ParseQuery(location.Query); // Set transport. properties on this (the factory) URISupport.SetProperties(this, map, "transport."); Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port); Socket socket = Connect(location.Host, location.Port); #if !NETCF socket.ReceiveBufferSize = ReceiveBufferSize; socket.SendBufferSize = SendBufferSize; socket.ReceiveTimeout = ReceiveTimeout; socket.SendTimeout = SendTimeout; #endif IWireFormat wireformat = CreateWireFormat(map); ITransport transport = new TcpTransport(location, socket, wireformat); wireformat.Transport = transport; if (UseLogging) { transport = new LoggingTransport(transport); } if (UseInactivityMonitor) { transport = new InactivityMonitor(transport); } if (wireformat is OpenWireFormat) { transport = new WireFormatNegotiator(transport, (OpenWireFormat)wireformat); } transport.RequestTimeout = this.requestTimeout; if (setTransport != null) { setTransport(transport, location); } return(transport); }
public ITransport CompositeConnect(Uri location, SetTransport setTransport) { // Extract query parameters from broker Uri StringDictionary map = URISupport.ParseQuery(location.Query); // Set transport. properties on this (the factory) URISupport.SetProperties(this, map, "transport."); // See if there is a local address and port specified string localAddress = null; int localPort = -1; if(!String.IsNullOrEmpty(location.AbsolutePath) && !location.AbsolutePath.Equals("/")) { int index = location.AbsolutePath.IndexOf(':'); try { localPort = Int16.Parse(location.AbsolutePath.Substring(index + 1)); localAddress = location.AbsolutePath.Substring(1, index - 1); Tracer.DebugFormat("Binding Socket to {0} on port: {1}", localAddress, localPort); } catch { Tracer.Warn("Invalid Port value on URI for local bind option, ignoring."); } } Tracer.Debug("Opening socket to: " + location.Host + " on port: " + location.Port); Socket socket = DoConnect(location.Host, location.Port, localAddress, localPort ); #if !NETCF socket.ReceiveBufferSize = ReceiveBufferSize; socket.SendBufferSize = SendBufferSize; socket.ReceiveTimeout = ReceiveTimeout; socket.SendTimeout = SendTimeout; #endif OpenWireFormat wireformat = new OpenWireFormat(); // Set wireformat. properties on the wireformat owned by the tcpTransport URISupport.SetProperties(wireformat.PreferredWireFormatInfo, map, "wireFormat."); ITransport transport = DoCreateTransport(location, socket, wireformat); wireformat.Transport = transport; if(UseLogging) { transport = new LoggingTransport(transport); } if(UseInactivityMonitor) { transport = new InactivityMonitor(transport); } transport = new WireFormatNegotiator(transport, wireformat); if(setTransport != null) { setTransport(transport, location); } return transport; }