Inheritance: IChannelSender, ISecurableChannel
Esempio n. 1
0
        protected void Application_Start() {
            DynaTraceADKFactory.initialize();
            
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            //init log4net
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4netConfig.xml");
            XmlConfigurator.Configure(new FileInfo(path));
            log.Info("application start b2b frontend");

            //init propertyfile
            ConfigUtil.InitPropertyFile();
            
            //load plugins
            PluginLoader.LoadAvailablePlugins();

            //start remoting client
            remotingChannel = new TcpClientChannel();
            ChannelServices.RegisterChannel(remotingChannel);
            RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTime), 
                "tcp://" + ConfigUtil.GetString("remotingHost") + ":" + ConfigUtil.GetInt("remotingPort") + "/remoteTime");
            
            //empty temp dir
            string tempDir = ConfigUtil.GetUserAppDir("temp.net");
            foreach (var f in Directory.GetFiles(tempDir)) {
                File.Delete(f);
            }
            AppDomain.CurrentDomain.SetData("tempDir", tempDir);
            log.Info("tempdir is:" + tempDir);
        }
        internal TcpClientTransportSink(String channelURI, TcpClientChannel channel)
        {
            String objectURI;

            _channel = channel;
            String simpleChannelUri = TcpChannelHelper.ParseURL(channelURI, out objectURI);

            ClientSocketCache = new SocketCache(new SocketHandlerFactory(this.CreateSocketHandler), _socketCachePolicy,
                                                _socketCacheTimeout);
            // extract machine name and port
            Uri uri = new Uri(simpleChannelUri);

            if (uri.IsDefaultPort)
            {
                // If there is no colon, then there is no port number.
                throw new RemotingException(
                          String.Format(
                              CultureInfo.CurrentCulture, CoreChannel.GetResourceString(
                                  "Remoting_Tcp_UrlMustHavePort"),
                              channelURI));
            }
            m_machineName = uri.Host;
            m_port        = uri.Port;

            _machineAndPort = m_machineName + ":" + m_port;
        } // TcpClientTransportSink
        /// <summary>
        /// Start connection with specified engine interface
        /// </summary>
        /// <param name="typeEngineInterface">Type of engine interface</param>
        /// <param name="urlClient">Asscoiated URL</param>
        /// <param name="ensureSecurity">Remoting security attribute</param>
        public void Start(string urlClient, bool ensureSecurity, uint timeOut, Type iProxyType)
        {
            Trace.TraceInformation("Configuring client connection");

            _ensureSecurity = ensureSecurity;

            #if MONO
            _sinkProvider = new BinaryClientFormatterSinkProvider();
            #endif
            IDictionary t = new Hashtable();
            t.Add("timeout", timeOut);
            t.Add("name", urlClient);

            // need to make ChannelNames unique so need to use this
            // constructor even though we dont care about the sink provider
            _channel = new TcpClientChannel(t, _sinkProvider);

            ChannelServices.RegisterChannel(_channel, _ensureSecurity);

            Trace.TraceInformation("Configured client connection");

            _base = (IBase)Activator.GetObject(iProxyType, urlClient);

            Trace.TraceInformation("Acquired proxy");
        }
Esempio n. 4
0
        } // TcpChannel

        /// <include file='doc\CombinedTcpChannel.uex' path='docs/doc[@for="TcpChannel.TcpChannel2"]/*' />
        public TcpChannel(IDictionary properties,
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();

            bool portFound = false;

            // divide properties up for respective channels
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;

                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value); break;

                    // client properties (none yet)

                    // server properties
                    case "bindTo": serverData["bindTo"] = entry.Value; break;

                    case "machineName": serverData["machineName"] = entry.Value; break;

                    case "port":
                    {
                        serverData["port"] = entry.Value;
                        portFound          = true;
                        break;
                    }

                    case "rejectRemoteRequests": serverData["rejectRemoteRequests"] = entry.Value; break;

                    case "suppressChannelData": serverData["suppressChannelData"] = entry.Value; break;

                    case "useIpAddress": serverData["useIpAddress"] = entry.Value; break;

                    default:
                        throw new ArgumentException(
                                  String.Format(
                                      CoreChannel.GetResourceString(
                                          "Remoting_Channels_BadCtorArgs"),
                                      entry.Key));
                    }
                }
            }

            _clientChannel = new TcpClientChannel(clientData, clientSinkProvider);

            if (portFound)
            {
                _serverChannel = new TcpServerChannel(serverData, serverSinkProvider);
            }
        } // TcpChannel
Esempio n. 5
0
        static void Main(string[] args)
        {
            try
            {
                // log...
                var writer = new EchoWriter();
                Logger.RegisterLogWriter(writer);
                Logger.Log(string.Format("MoqRT Baking Instructor - v{0}", typeof(BakingEndPoint).Assembly.GetName().Version));

                // tcp...
                var client = new TcpClientChannel();
                string uri = string.Format("tcp://{0}:{1}/{2}",
                         Environment.MachineName, BakingEndPoint.Port, BakingEndPoint.ServiceUri);
                BakingEndPoint ep = (BakingEndPoint)Activator.GetObject(typeof(BakingEndPoint), uri);
                ManualResetEvent e = null;
                try
                {
                }
                catch (SocketException ex)
                {
                    Logger.Log(ex.Message);
                    Logger.Log("-----------------------");
                    Logger.Log(string.Format("Failed to connect to URI '{0}'. Check that the MoqRT Baker client is running.", uri));

                    // return...
                    Environment.ExitCode = 2;
                    return;
                }

                // log...
//                ep.RegisterLogWriter(writer);
                try
                {
                    e = ep.ForceBaking();

                    // wait...
                    Logger.Log("Now waiting for baking...");
                    e.WaitOne();
                }
                finally
                {
  //                  ep.UnregisterLogWriter(writer);
                }

                // o...
                Logger.Log("All done.");
            }
            catch(Exception ex)
            {
                Logger.Log("Fatal error.", ex);
                Environment.ExitCode = 1;
            }
        }
		void Init (IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
		{
			_clientChannel = new TcpClientChannel (properties,clientSink);

			if(properties["port"] != null)
				_serverChannel = new TcpServerChannel(properties, serverSink);

			object val = properties ["name"];
			if (val != null) _name = val as string;
			
			val = properties ["priority"];
			if (val != null) _priority = Convert.ToInt32 (val);
		}
Esempio n. 7
0
        public static void createChannelTcp()
        {
            TcpClientChannel chan = new TcpClientChannel();
            ChannelServices.RegisterChannel(chan, false);
            AdminLogger.WriteEvent("Client channel created.",
                ZifliForm._DEBUG);

            /*svcController obj = (svcController)Activator.GetObject(
                typeof(ZifliService.svcController),
                "tcp://localhost:11975/ZifliService");
            AdminLogger.WriteEvent("Activator established.",
                ZifliForm._DEBUG);*/
        }
        public TcpChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
        {
            this._channelPriority = 1;
            this._channelName     = "tcp";
            Hashtable hashtable  = new Hashtable();
            Hashtable hashtable2 = new Hashtable();
            bool      flag       = false;

            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    string key = (string)entry.Key;
                    if (key == null)
                    {
                        goto Label_00CB;
                    }
                    if (!(key == "name"))
                    {
                        if (key == "priority")
                        {
                            goto Label_0097;
                        }
                        if (key == "port")
                        {
                            goto Label_00B5;
                        }
                        goto Label_00CB;
                    }
                    this._channelName = (string)entry.Value;
                    continue;
Label_0097:
                    this._channelPriority = Convert.ToInt32((string)entry.Value, CultureInfo.InvariantCulture);
                    continue;
Label_00B5:
                    hashtable2["port"] = entry.Value;
                    flag = true;
                    continue;
Label_00CB:
                    hashtable[entry.Key]  = entry.Value;
                    hashtable2[entry.Key] = entry.Value;
                }
            }
            this._clientChannel = new TcpClientChannel(hashtable, clientSinkProvider);
            if (flag)
            {
                this._serverChannel = new TcpServerChannel(hashtable2, serverSinkProvider);
            }
        }
 public TcpChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
 {
     this._channelPriority = 1;
     this._channelName = "tcp";
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     bool flag = false;
     if (properties != null)
     {
         foreach (DictionaryEntry entry in properties)
         {
             string key = (string) entry.Key;
             if (key == null)
             {
                 goto Label_00CB;
             }
             if (!(key == "name"))
             {
                 if (key == "priority")
                 {
                     goto Label_0097;
                 }
                 if (key == "port")
                 {
                     goto Label_00B5;
                 }
                 goto Label_00CB;
             }
             this._channelName = (string) entry.Value;
             continue;
         Label_0097:
             this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture);
             continue;
         Label_00B5:
             hashtable2["port"] = entry.Value;
             flag = true;
             continue;
         Label_00CB:
             hashtable[entry.Key] = entry.Value;
             hashtable2[entry.Key] = entry.Value;
         }
     }
     this._clientChannel = new TcpClientChannel(hashtable, clientSinkProvider);
     if (flag)
     {
         this._serverChannel = new TcpServerChannel(hashtable2, serverSinkProvider);
     }
 }
Esempio n. 10
0
File: Form1.cs Progetto: trasa/Wotan
        private void Form1_Load(object sender, EventArgs e)
        {
            TcpClientChannel channel = new TcpClientChannel();
            ChannelServices.RegisterChannel(channel, false);

            conn = (UniverseConnection)Activator.GetObject(
                typeof(UniverseConnection),
                "tcp://localhost:8085/UniverseConnection");
            conn.MessagePending += new EventHandler(conn_MessagePending);
            conn.DebugMessage("Hi");
            //for (int i = 0; i < 10; i++)
            //{
            //    conn.DebugMessage(DateTime.Now.ToString());
            //    System.Threading.Thread.Sleep(500);
            //}
        }
Esempio n. 11
0
File: Client.cs Progetto: mono/gert
		static int Main ()
		{
			TcpClientChannel channel = new TcpClientChannel ();
#if NET_2_0
			ChannelServices.RegisterChannel (channel, false);
#else
			ChannelServices.RegisterChannel (channel);
#endif
			IRemoteObject target = (IRemoteObject) Activator.GetObject (
				typeof (IRemoteObject),
				"tcp://localhost:7777/remote-object"
			);
			if (target.DoIt () != 2)
				return 1;
			return 0;
		}
Esempio n. 12
0
        static void Main(string[] args)
        {
            TcpClientChannel channel = new TcpClientChannel();
            ChannelServices.RegisterChannel(channel, false);

            UniverseConnection conn = (UniverseConnection)Activator.GetObject(
                typeof(UniverseConnection),
                "tcp://localhost:8085/UniverseConnection");

            conn.DebugMessage("Hi");
            for (int i = 0; i < 10; i++)
            {
                conn.DebugMessage(DateTime.Now.ToString());
                System.Threading.Thread.Sleep(500);
            }
        }
Esempio n. 13
0
        } // TcpChannel

        public TcpChannel(IDictionary properties,
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();

            bool portFound = false;

            // divide properties up for respective channels
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;

                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break;

                    case "port":
                    {
                        serverData["port"] = entry.Value;
                        portFound          = true;
                        break;
                    }

                    default:
                        clientData[entry.Key] = entry.Value;
                        serverData[entry.Key] = entry.Value;
                        break;
                    }
                }
            }

            _clientChannel = new TcpClientChannel(clientData, clientSinkProvider);

            if (portFound)
            {
                _serverChannel = new TcpServerChannel(serverData, serverSinkProvider);
            }
        } // TcpChannel
 internal TcpClientTransportSink(string channelURI, TcpClientChannel channel)
 {
     string str;
     this._socketCacheTimeout = TimeSpan.FromSeconds(10.0);
     this._spn = string.Empty;
     this._retryCount = 1;
     this._tokenImpersonationLevel = TokenImpersonationLevel.Identification;
     this._protectionLevel = ProtectionLevel.EncryptAndSign;
     this._channel = channel;
     string uriString = TcpChannelHelper.ParseURL(channelURI, out str);
     this.ClientSocketCache = new SocketCache(new SocketHandlerFactory(this.CreateSocketHandler), this._socketCachePolicy, this._socketCacheTimeout);
     Uri uri = new Uri(uriString);
     if (uri.IsDefaultPort)
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_UrlMustHavePort"), new object[] { channelURI }));
     }
     this.m_machineName = uri.Host;
     this.m_port = uri.Port;
     this._machineAndPort = this.m_machineName + ":" + this.m_port;
 }
Esempio n. 15
0
        } // TcpChannel

        public TcpChannel(IDictionary properties, 
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();

            bool portFound = false;
        
            // divide properties up for respective channels
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;
                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break;
                    case "port": 
                    {
                        serverData["port"] = entry.Value; 
                        portFound = true;
                        break;
                    }

                    default: 
                            clientData[entry.Key] = entry.Value;
                            serverData[entry.Key] = entry.Value;
                            break;
                    }
                }                    
            }

            _clientChannel = new TcpClientChannel(clientData, clientSinkProvider);

            if (portFound)
                _serverChannel = new TcpServerChannel(serverData, serverSinkProvider);
        } // TcpChannel
        internal TcpClientTransportSink(string channelURI, TcpClientChannel channel)
        {
            string str;

            this._socketCacheTimeout = TimeSpan.FromSeconds(10.0);
            this._spn        = string.Empty;
            this._retryCount = 1;
            this._tokenImpersonationLevel = TokenImpersonationLevel.Identification;
            this._protectionLevel         = ProtectionLevel.EncryptAndSign;
            this._channel = channel;
            string uriString = TcpChannelHelper.ParseURL(channelURI, out str);

            this.ClientSocketCache = new SocketCache(new SocketHandlerFactory(this.CreateSocketHandler), this._socketCachePolicy, this._socketCacheTimeout);
            Uri uri = new Uri(uriString);

            if (uri.IsDefaultPort)
            {
                throw new RemotingException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Remoting_Tcp_UrlMustHavePort"), new object[] { channelURI }));
            }
            this.m_machineName   = uri.Host;
            this.m_port          = uri.Port;
            this._machineAndPort = this.m_machineName + ":" + this.m_port;
        }
Esempio n. 17
0
        void Init(IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
        {
            _clientChannel = new TcpClientChannel(properties, clientSink);

            if (properties != null)
            {
                if (properties["port"] != null)
                {
                    _serverChannel = new TcpServerChannel(properties, serverSink);
                }

                object val = properties ["name"];
                if (val != null)
                {
                    _name = val as string;
                }

                val = properties ["priority"];
                if (val != null)
                {
                    _priority = Convert.ToInt32(val);
                }
            }
        }
Esempio n. 18
0
        public bool Connect(string IP,int puertol,string clave,int puertor)
        {
            m_ip = IPAddress.Parse(IP);
            if (puertor!=0)
                this.m_puertos=puertor;

            this.m_url="tcp://" + IP + ":" + this.m_puertos + "/InterfazRemota";
            this.m_puertor=puertor;

            System.Security.Cryptography.MD5 cripto=System.Security.Cryptography.MD5.Create();

            bool valor=false;
            try
            {
                m_lPhantChannel = new TcpClientChannel(props, provider);
                ChannelServices.RegisterChannel(m_lPhantChannel);
            }
            catch
            {
                DisConnect();
                if (m_lPhantChannel!=null)
                    ChannelServices.RegisterChannel(m_lPhantChannel);
                else
                    m_lPhantChannel = new TcpClientChannel(props, provider);
            }
            interfazremota = (CInterfaceGateway) Activator.GetObject(typeof(eLePhant.eDonkey.CInterfaceGateway),
                this.m_url);

            if (interfazremota == null)
                Debug.Write("No se pudo encontrar el servidor");
            else
            {
                //c = new byte[clave.Length];
                //for (int i=0;i<clave.Length;i++) c[i]=System.Convert.ToByte(clave[i]);
                //cripto.ComputeHash(c);
                //try
                //{
                valor = interfazremota.CheckPw( clave );
                /*}
                catch
                {
                    ChannelServices.UnregisterChannel(this.canalCeLephant);
                    this.canalCeLephant = null;
                    Debug.Write("\nNo se pudo encontrar el servidor\n");
                }*/
            }
            return valor;
        }
		/**
		 * Opens a new connection to the Swarm
		 *
		 * @param CallbackFunc The callback function Swarm will use to communicate back to the Instigator
		 *
		 * @return An INT containing the error code (if < 0) or the handle (>= 0) which is useful for debugging only
		 */
		public virtual Int32 OpenConnection(FConnectionCallback CallbackFunc, IntPtr CallbackData, ELogFlags LoggingFlags, string OptionsFolder)
		{
			// Checked here so we can time OpenConnection
			if ((LoggingFlags & ELogFlags.LOG_TIMINGS) == ELogFlags.LOG_TIMINGS)
			{
				PerfTimerInstance = new PerfTimer();
			}

			StartTiming("OpenConnection-Managed", true);

			// Establish a connection to the local Agent server object
			ConnectionHandle = Constants.INVALID;
			Int32 ReturnValue = Constants.INVALID;
			try
			{
				EditorLog(EVerbosityLevel.Informative, "[OpenConnection] Registering TCP channel ...");

				// Start up network services, by opening a network communication channel
				NetworkChannel = new TcpClientChannel();
				ChannelServices.RegisterChannel(NetworkChannel, false);

				// See if an agent is already running, and if not, launch one
				EnsureAgentIsRunning(OptionsFolder);
				if (AgentProcess != null)
				{
					EditorLog(EVerbosityLevel.Informative, "[OpenConnection] Connecting to agent ...");
					ReturnValue = TryOpenConnection(CallbackFunc, CallbackData, LoggingFlags);
					if (ReturnValue >= 0)
					{
						AgentCacheFolder = ConnectionConfiguration.AgentCachePath;
						if (AgentCacheFolder.Length == 0)
						{
							EditorLog(EVerbosityLevel.Critical, "[OpenConnection] Agent cache folder with 0 length.");
							CloseConnection();
							ReturnValue = Constants.ERROR_FILE_FOUND_NOT;
						}
					}
				}
				else
				{
					EditorLog(EVerbosityLevel.Critical, "[OpenConnection] Failed to find Swarm Agent");
                    ReturnValue = Constants.ERROR_FILE_FOUND_NOT;
				}
			}
			catch (Exception Ex)
			{
				EditorLog(EVerbosityLevel.Critical, "[OpenConnection] Error: " + Ex.Message);
				ReturnValue = Constants.ERROR_EXCEPTION;
			}

			// Finally, if there have been no errors, assign the connection handle 
			if (ReturnValue >= 0)
			{
				ConnectionHandle = ReturnValue;
			}
			else
			{
				// If we've failed for any reason, call the clean up routine
				CleanupClosedConnection();
			}

			StopTiming();
			return ReturnValue;
		}
Esempio n. 20
0
 private void Form1_Load(object sender, EventArgs e)
 {
     TcpClientChannel chanel = new TcpClientChannel();
     ChannelServices.RegisterChannel(chanel, false);
     RemotingConfiguration.RegisterWellKnownClientType(typeof(Calculadora), "tcp://localhost:1235/Calculadora");
 }
Esempio n. 21
0
        } // TcpChannel

        /// <include file='doc\CombinedTcpChannel.uex' path='docs/doc[@for="TcpChannel.TcpChannel2"]/*' />
        public TcpChannel(IDictionary properties, 
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();

            bool portFound = false;
        
            // divide properties up for respective channels
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;
                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value); break;

                    // client properties (none yet)

                    // server properties
                    case "bindTo": serverData["bindTo"] = entry.Value; break;
                    case "machineName": serverData["machineName"] = entry.Value; break; 
                    
                    case "port": 
                    {
                        serverData["port"] = entry.Value; 
                        portFound = true;
                        break;
                    }
                    case "rejectRemoteRequests": serverData["rejectRemoteRequests"] = entry.Value; break;
                    case "suppressChannelData": serverData["suppressChannelData"] = entry.Value; break;
                    case "useIpAddress": serverData["useIpAddress"] = entry.Value; break;

                    default: 
                         throw new ArgumentException(
                            String.Format(
                                CoreChannel.GetResourceString(
                                    "Remoting_Channels_BadCtorArgs"),
                                entry.Key));
                    }
                }                    
            }

            _clientChannel = new TcpClientChannel(clientData, clientSinkProvider);

            if (portFound)
                _serverChannel = new TcpServerChannel(serverData, serverSinkProvider);
        } // TcpChannel
Esempio n. 22
0
 private void NewRemoteGameMenuItem_Click(object sender, System.EventArgs e)
 {
     try
     {
         TcpClientChannel client = new TcpClientChannel();
         ChannelServices.RegisterChannel(client);
         ServerInterface.ServerObject server;
         server = (ServerInterface.ServerObject) Activator.GetObject(typeof(ServerInterface.ServerObject), "tcp://localhost:2000/teste");
         server.Register("teste");
         ChannelServices.UnregisterChannel(client);
     }
     catch(Exception exp)
     {
         MessageBox.Show(exp.Message);
     }
 }
        internal TcpClientTransportSink(String channelURI, TcpClientChannel channel)
        {
            String objectURI;
            _channel = channel;
            String simpleChannelUri = TcpChannelHelper.ParseURL(channelURI, out objectURI);
            ClientSocketCache = new SocketCache(new SocketHandlerFactory(this.CreateSocketHandler), _socketCachePolicy,
                                                     _socketCacheTimeout);
            // extract machine name and port
            Uri uri = new Uri(simpleChannelUri);

            if (uri.IsDefaultPort)
            {
                // If there is no colon, then there is no port number.
                throw new RemotingException(
                    String.Format(
                        CultureInfo.CurrentCulture, CoreChannel.GetResourceString(
                            "Remoting_Tcp_UrlMustHavePort"),
                        channelURI));
            }
            m_machineName = uri.Host;
            m_port = uri.Port;

            _machineAndPort = m_machineName + ":" + m_port;
        } // TcpClientTransportSink
Esempio n. 24
0
        //return null for Fail
        public static Object GetRemoteObj(System.Type type,System.Runtime.Remoting.Channels.Tcp.TcpClientChannel tcp,string url)
        {
            if (tcp != null)
            {
                foreach (System.Runtime.Remoting.Channels.IChannel tcpchannel in System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels)
                {
                    if(tcp.ChannelName==tcpchannel.ChannelName)
                        System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(tcpchannel);
                }
            }
            else
                tcp = new System.Runtime.Remoting.Channels.Tcp.TcpClientChannel(url,null);

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tcp, false);

               System.Object obj = null;

            try
            {

                obj = Activator.GetObject(
                    type,
                    url);
                ((RemoteClassBase)obj).HelloWorld();
            }
            catch(Exception ex)
            {
                obj = null;
                try
                {
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(tcp);
                }
                catch { }
                throw new Exception(ex.Message+ex.StackTrace);

            }
            finally
            {

            }
            return obj;
        }
        private String _channelName = "tcp"; // channel name


        public TcpChannel()
        {
            _clientChannel = new TcpClientChannel();
            // server channel will not be activated.
        } // TcpChannel
Esempio n. 26
0
        FSwarmInterface()
        {
            AgentProcess = null;
            AgentProcessOwner = false;
            Connection = null;
            ConnectionHandle = Constants.INVALID;
            ConnectionMessageThread = null;
            ConnectionMonitorThread = null;
            ConnectionConfiguration = null;
            ConnectionCallback = null;
            BaseChannelHandle = 0;
            PendingTasks = null;
            NetworkChannel = null;
            PerfTimerInstance = null;

            OpenChannels = new ReaderWriterDictionary<Int32, ChannelInfo>();
            FreeChannelWriteBuffers = new Stack<byte[]>();
            CleanupClosedConnectionLock = new Object();

            // TODO: Delete old files
        }
Esempio n. 27
0
 public bool Connect(string IP,string key,int port2)
 {
     m_ip = IPAddress.Parse(IP);
     if (port2!=0)
     this.m_Port=port2;
     this.m_url="tcp://" + IP + ":" + this.m_Port + "/RemoteInterface";
     this.m_Port2=port2;
     System.Security.Cryptography.MD5 cripto=System.Security.Cryptography.MD5.Create();
     bool valor=false;
     try
     {
     m_lPhantChannel = new TcpClientChannel(props, provider);
     ChannelServices.RegisterChannel(m_lPhantChannel, true);
     }
     catch
     {
     DisConnect();
     if (m_lPhantChannel!=null)
         ChannelServices.RegisterChannel(m_lPhantChannel, true);
     else
         m_lPhantChannel = new TcpClientChannel(props, provider);
     }
     remoteInterface = (CInterfaceGateway) Activator.GetObject(typeof(CInterfaceGateway),
                  this.m_url);
     if (remoteInterface == null)
     Debug.Write("Could not locate the server");
     else
     {
     try
     {
         valor = remoteInterface.CheckPw( key );
     }
     catch
     {
         Debug.Write("\nCould not locate the server\n");
     }
     }
     return valor;
 }
 public TcpChannel()
 {
     this._channelPriority = 1;
     this._channelName = "tcp";
     this._clientChannel = new TcpClientChannel();
 }
Esempio n. 29
0
        /// <summary>
        /// TODO:
        /// </summary>
        protected void registerTcpClientChannel()
        {
            var properties = new Hashtable();

            properties["includeVersions"] = "false";

            var sinkProvider =
                new BinaryClientFormatterSinkProvider(properties, null);

            var tcpChannel = new TcpClientChannel(String.Empty, sinkProvider);

            ChannelServices.RegisterChannel(tcpChannel);

            _tcpClientChannelRegistered = true;
        }
Esempio n. 30
0
		/// <summary>
		/// Client-side call
		/// </summary>
		/// <param name="port"></param>
		/// <returns></returns>
		public static IHNDBSVR Connect(string ServerName_or_IP, int port)
		{
			try
			{
				lock(ChannelServices.RegisteredChannels)
				{
					bool bRegister=false;
					foreach(IChannel chan in ChannelServices.RegisteredChannels)
					{
						if(chan.ChannelName=="tcp")
						{
							bRegister=true;
						}
					}
					if(!bRegister)
					{
						try
						{
							TcpClientChannel chan = new TcpClientChannel();
							ChannelServices.RegisterChannel(chan);
						}
						catch
						{
						}
					}
				}

				IHNDBSVR obj = (IHNDBSVR)Activator.GetObject(typeof(IHNDBSVR), 
					"tcp://"+ServerName_or_IP+":"+port.ToString()+"/HNDBSVR");
				return obj;
			}
			catch(Exception e)
			{
				return null;
			}
		}
Esempio n. 31
0
        public Transcoder()
        {
            // first, we need to identify where Transcode 360 was installed (if at all)
            RegistryKey key = Registry.LocalMachine;
            key = key.OpenSubKey(@"SOFTWARE\Transcode360");
            if (key == null) { return; }

            object installPath = key.GetValue("InstallPath");
            key.Close();
            if (installPath == null) { return; }
            InstallPath = installPath.ToString();

            // now that we have an installation path, let's make sure the dll is available
            if (File.Exists(InstallPath + "\\Transcode360.Interface.dll"))
            {
               
                ITranscode360 = LoadTranscode360(installPath + "\\Transcode360.Interface.dll");
                if (ITranscode360 == null) { return; }
                Hashtable properties = new Hashtable();
                properties.Add("name", "");
                Channel = new TcpClientChannel(properties, null);
                ChannelServices.RegisterChannel(Channel, false);

                Server = Activator.GetObject(ITranscode360,
                   "tcp://localhost:1401/RemotingServices/Transcode360");
                
        
                ParameterModifier[] arrPmods = new ParameterModifier[1];
                arrPmods[0] = new ParameterModifier(1);
                arrPmods[0][0] = false; // not out
                
                System.Type[] arrTypes = new System.Type[1];
                arrTypes.SetValue(Type.GetType("System.String"),0);

                methStopTranscoding = ITranscode360.GetMethod("StopTranscoding",
                    arrTypes,
                    arrPmods);          

                // IsMediaTranscodeComplete
                arrPmods[0] = new ParameterModifier(3);
                arrPmods[0][0] = false; // not out
                arrPmods[0][1] = false;
                arrPmods[0][2] = true;

                arrTypes = new System.Type[3];
                arrTypes.SetValue(Type.GetType("System.String"), 0);
                arrTypes.SetValue(Type.GetType("System.Int64"), 1);
                arrTypes.SetValue(Type.GetType("System.String&"), 2);
                
                methIsMediaTranscodeComplete = ITranscode360.GetMethod("IsMediaTranscodeComplete",
                    arrTypes,
                    arrPmods);

                // IsMediaTranscoding
                arrPmods[0] = new ParameterModifier(3);
                arrPmods[0][0] = false; // not out
                arrPmods[0][1] = false;
                arrPmods[0][2] = true;

                arrTypes = new System.Type[3];
                arrTypes.SetValue(Type.GetType("System.String"), 0);
                arrTypes.SetValue(Type.GetType("System.Int64"), 1);
                arrTypes.SetValue(Type.GetType("System.String&"), 2);

                methIsMediaTranscoding = ITranscode360.GetMethod("IsMediaTranscoding",
                    arrTypes,
                    arrPmods);

                // Transcode
                arrPmods[0] = new ParameterModifier(3);
                arrPmods[0][0] = false; // not out
                arrPmods[0][1] = true;
                arrPmods[0][2] = false;
                
                arrTypes = new System.Type[3];
                arrTypes.SetValue(Type.GetType("System.String"), 0);
                arrTypes.SetValue(Type.GetType("System.String&"), 1);
                arrTypes.SetValue(Type.GetType("System.Int64"), 2);

                methTranscode = ITranscode360.GetMethod("Transcode",
                    arrTypes,
                    arrPmods);
             }
        }
 public TcpChannel()
 {
     this._channelPriority = 1;
     this._channelName     = "tcp";
     this._clientChannel   = new TcpClientChannel();
 }
Esempio n. 33
0
        /*
         * Clean up all of the remainders from a closed connection, including the network channels, etc.
         */
        Int32 CleanupClosedConnection()
        {
            Monitor.Enter(CleanupClosedConnectionLock);

            // NOTE: Do not make any calls to the real Connection in here!
            // If, for any reason, the connection has died, calling into it from here will
            // end up causing this thread to hang, waiting for the dead connection to respond.
            DebugLog.Write("[Interface:CleanupClosedConnection] Closing all connections to the Agent");

            // Reset all necessary assigned variables
            AgentProcess = null;
            AgentProcessOwner = false;

            if (Connection != null)
            {
                // Notify the connection wrapper that the connection is gone
                Connection.SignalConnectionDropped();
                Connection = null;
            }
            ConnectionHandle = Constants.INVALID;
            ConnectionConfiguration = null;

            // Clean up and close up the connection callback
            if (ConnectionCallback != null)
            {
                IntPtr QuitMessage = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FMessage)));
                Marshal.StructureToPtr(new FMessage(ESwarmVersionValue.VER_1_0, EMessageType.QUIT), QuitMessage, false);
                ConnectionCallback(QuitMessage, ConnectionCallbackData);
            }
            ConnectionCallback = null;
            ConnectionCallbackData = IntPtr.Zero;

            // Close all associated channels
            if (OpenChannels.Count > 0)
            {
                foreach (ChannelInfo NextChannel in OpenChannels.Values)
                {
                    // Just close the handle and we'll clear the entire list later
                    if (NextChannel.ChannelFileStream != null)
                    {
                        NextChannel.ChannelFileStream.Close();
                        NextChannel.ChannelFileStream = null;
                    }
                }
                OpenChannels.Clear();
            }

            // Unregister the primary network communication channel
            if (NetworkChannel != null)
            {
                ChannelServices.UnregisterChannel(NetworkChannel);
                NetworkChannel = null;
            }

            Monitor.Exit(CleanupClosedConnectionLock);

            return Constants.SUCCESS;
        }
Esempio n. 34
0
 public bool Connect(string IP,int port3,string key,int port2)
 {
     m_ip = IPAddress.Parse(IP);
     if (port2!=0)
     this.m_Port=port2;
     this.m_url="tcp://" + IP + ":" + this.m_Port + "/RemoteInterface";
     this.m_Port2=port2;
     System.Security.Cryptography.MD5 cripto=System.Security.Cryptography.MD5.Create();
     bool valor=false;
     try
     {
     m_lPhantChannel = new TcpClientChannel(props, provider);
     ChannelServices.RegisterChannel(m_lPhantChannel, true);
     }
     catch
     {
     DisConnect();
     if (m_lPhantChannel!=null)
         ChannelServices.RegisterChannel(m_lPhantChannel, true);
     else
         m_lPhantChannel = new TcpClientChannel(props, provider);
     }
     remoteInterface = (CInterfaceGateway) Activator.GetObject(typeof(CInterfaceGateway),
                  this.m_url);
     if (remoteInterface == null)
     Debug.Write("Could not locate the server");
     else
     {
     //c = new byte[key.Length];
     //for (int i=0;i<key.Length;i++) c[i]=System.Convert.ToByte(key[i]);
     //cripto.ComputeHash(c);
     //try
     //{
     valor = remoteInterface.CheckPw( key );
     /*}
     catch
     {
         ChannelServices.UnregisterChannel(this.canalCeLephant);
         this.canalCeLephant = null;
         Debug.Write("\nNo se pudo encontrar el servidor\n");
     }*/
     }
     return valor;
 }
Esempio n. 35
0
		TcpClientChannel GetClientChannel (string name, string uri)
		{
			TcpClientChannel clientChannel = new TcpClientChannel (name + "Client", null);
			ChannelServices.RegisterChannel (clientChannel);
			
			WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry (
				typeof (RemoteObject), uri + "/RemoteObject.rem");
			RemotingConfiguration.RegisterWellKnownClientType (remoteType);
			
			return clientChannel;
		}
Esempio n. 36
0
        public override void Initialize()
        {
            if (!pRunningLocal)
            {
                try
                {
                    System.Collections.IDictionary properties = new Hashtable();
                    properties["timeout"] = pTimeOut;
                    channel = new TcpClientChannel(properties, null);
                    ChannelServices.RegisterChannel(channel, false);
                    Victor = (VictorStandAloneToDll)Activator.GetObject(typeof(VictorStandAloneToDll), "tcp://" + pIPAddress + "/VictorRemote", null);
                    Thread.Sleep(2000);
                    //Victor = new VictorStandAloneToDll();
                    Victor.InitializePlateReaderPublic();
                    //Victor.StatusChange += new VictorStandAloneToDll.StatusChangeHandler(Victor_StatusChange);
                    StatusOK = true;
                }
                catch (Exception thrown)
                {
                    StatusOK = false;
                    throw new InstrumentError("Could not initialize plate reader", this, thrown);
                }
            }
            else
            {
                try
                {
                    InitializeVictorLocal();
                    StatusOK = true;
                }
                catch (Exception thrown)
                {
                    StatusOK = false;
                    throw new InstrumentError("Could not initialize plate reader", this, thrown);
                }

            }
        }
        private String _channelName  = "tcp";           // channel name


        /// <include file='doc\CombinedTcpChannel.uex' path='docs/doc[@for="TcpChannel.TcpChannel"]/*' />
        public TcpChannel()
        {
            _clientChannel = new TcpClientChannel();
            // server channel will not be activated.
        } // TcpChannel
Esempio n. 38
0
        public bool Connect(string IP,string clave,int puertor)
        {
            m_ip = IPAddress.Parse(IP);
            if (puertor!=0)
                this.m_puertos=puertor;

            this.m_url="tcp://" + IP + ":" + this.m_puertos + "/InterfazRemota";
            this.m_puertor=puertor;

            System.Security.Cryptography.MD5 cripto=System.Security.Cryptography.MD5.Create();

            bool valor=false;
            try
            {
                m_lPhantChannel = new TcpClientChannel(props, provider);
                ChannelServices.RegisterChannel(m_lPhantChannel);
            }
            catch
            {
                DisConnect();
                if (m_lPhantChannel!=null)
                    ChannelServices.RegisterChannel(m_lPhantChannel);
                else
                    m_lPhantChannel = new TcpClientChannel(props, provider);
            }
            interfazremota = (CInterfaceGateway) Activator.GetObject(typeof(eLePhant.eDonkey.CInterfaceGateway),
                this.m_url);

            if (interfazremota == null)
                Debug.Write("No se pudo encontrar el servidor");
            else
            {
                try
                {
                    valor = interfazremota.CheckPw( clave );
                }
                catch
                {
                    Debug.Write("\nNo se pudo encontrar el servidor\n");
                }
            }
            return valor;
        }