//private Belikov.GenuineChannels.GenuineTcp.GenuineTcpChannel channel; public HTTPTwoWayRemotingClient(int listenPort, int keepAliveIntervalSeconds) : base(keepAliveIntervalSeconds) { /*IDictionary sProps = new Hashtable(); sProps["algorithm"] = "3DES"; sProps["requireSecurity"] = "true"; sProps["connectionAgeLimit"] = "120"; sProps["sweepFrequency"] = "60";*/ BinaryServerFormatterSinkProvider binaryServerFormatSinkProvider = new BinaryServerFormatterSinkProvider(); binaryServerFormatSinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; //SecureServerChannelSinkProvider secureServerSinkProvider = new SecureServerChannelSinkProvider(sProps, null); //secureServerSinkProvider.Next = binaryServerFormatSinkProvider; BinaryClientFormatterSinkProvider binaryClientFormatSinkProvider = new BinaryClientFormatterSinkProvider(); //binaryClientFormatSinkProvider.Next = new SecureClientChannelSinkProvider(sProps, null); IDictionary props = new Hashtable(); props["port"] = listenPort; //props["useIpAddress"] = false; //props["clientConnectionLimit"] = 1; //props["rejectRemoteRequests"] = false; //props["ConnectTimeout"] = 15000; //props["InvocationTimeout"] = 15000; //props["Priority"] = "100"; //Belikov.GenuineChannels.Security.SecuritySessionServices.SetCurrentSecurityContext(new Belikov.GenuineChannels.Security.SecuritySessionParameters(Belikov.GenuineChannels.Security.SecuritySessionServices.DefaultContext.Name, Belikov.GenuineChannels.Security.SecuritySessionAttributes.ForceSync, TimeSpan.FromSeconds(15), Belikov.GenuineChannels.Connection.GenuineConnectionType.Persistent, null, TimeSpan.FromMinutes(5))); //channel = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, binaryClientFormatSinkProvider, secureServerSinkProvider); channel = new System.Runtime.Remoting.Channels.Tcp.TcpChannel(props, binaryClientFormatSinkProvider, binaryServerFormatSinkProvider); //channel = new System.Runtime.Remoting.Channels.Http.HttpChannel(props, binaryClientFormatSinkProvider, secureServerSinkProvider); //channel = new Belikov.GenuineChannels.GenuineTcp.GenuineTcpChannel(props, binaryClientFormatSinkProvider, binaryServerFormatSinkProvider); System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel); }
/// <summary> /// /// </summary> /// <returns></returns> private RemoteObject GetRemoteObject() { if (_remoteObject == null) { IDictionary tcpProperties = new Hashtable(); BinaryClientFormatterSinkProvider tcpClientSinkProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider tcpServerSinkProvider = new BinaryServerFormatterSinkProvider(); tcpServerSinkProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; tcpProperties["timeout"] = 5000; tcpProperties["port"] = 0; _tcpChannel = new TcpChannel( tcpProperties, tcpClientSinkProvider, tcpServerSinkProvider); ChannelServices.RegisterChannel(_tcpChannel, false); _remoteObject = (RemoteObject)Activator.GetObject( typeof(RemoteObject), "tcp://127.0.0.1:9000/RO" ); } return _remoteObject; }
/// <summary> /// Create a TcpChannel with a given name, on a given port. /// </summary> /// <param name="port"></param> /// <param name="name"></param> /// <returns></returns> private static TcpChannel CreateTcpChannel( string name, int port, int limit ) { ListDictionary props = new ListDictionary(); props.Add( "port", port ); props.Add( "name", name ); props.Add( "bindTo", "127.0.0.1" ); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); // NOTE: TypeFilterLevel and "clientConnectionLimit" property don't exist in .NET 1.0. Type typeFilterLevelType = typeof(object).Assembly.GetType("System.Runtime.Serialization.Formatters.TypeFilterLevel"); if (typeFilterLevelType != null) { PropertyInfo typeFilterLevelProperty = serverProvider.GetType().GetProperty("TypeFilterLevel"); object typeFilterLevel = Enum.Parse(typeFilterLevelType, "Full"); typeFilterLevelProperty.SetValue(serverProvider, typeFilterLevel, null); // props.Add("clientConnectionLimit", limit); } BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); return new TcpChannel( props, clientProvider, serverProvider ); }
private void RegisterChannels() { BinaryServerFormatterSinkProvider binaryServerProv = new BinaryServerFormatterSinkProvider(); binaryServerProv.TypeFilterLevel = TypeFilterLevel.Full; BinaryClientFormatterSinkProvider binaryClientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = clientPort; props["name"] = server + ":" + serverPort; IPAddress[] serverIpAddresses = Dns.GetHostAddresses(server); IPAddress serverSelectedIP = null; foreach (IPAddress address in serverIpAddresses) { if (address.AddressFamily == AddressFamily.InterNetwork) { serverSelectedIP = address; } } if (serverSelectedIP != null) { IPAddress address = NetHelper.GetIpAddressFromTheSameNetworkAs(serverSelectedIP); if (address != null) { props["machineName"] = address.ToString(); } } else { throw new Exception("Could not select an IP address for the server."); } chan = new TcpChannel(props, binaryClientProv, binaryServerProv); ChannelServices.RegisterChannel(chan); }
private IClientChannelSinkProvider CreateDefaultClientProviderChain() { IClientChannelSinkProvider provider = new BinaryClientFormatterSinkProvider(); IClientChannelSinkProvider provider2 = provider; provider2.Next = new IpcClientTransportSinkProvider(this._prop); return provider; }
public RemotingHostServer(Machine machine, int port, string name) : base(machine) { this.port = port; this.name = name; // TODO review this name, get machine name this.hostname = "localhost"; // According to http://www.thinktecture.com/resourcearchive/net-remoting-faq/changes2003 // in order to have ObjRef accessible from client code BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = port; TcpChannel channel = new TcpChannel(props, clientProv, serverProv); if (!registered) { ChannelServices.RegisterChannel(channel, false); registered = true; } // end of "according" // TODO review other options to publish an object this.objref = RemotingServices.Marshal(this, name); }
/// <summary> /// Sets up the services remoting channel /// </summary> public void Start() { try { System.Collections.Hashtable props = new System.Collections.Hashtable(); props["typeFilterLevel"] = "Full"; // Both formatters only use the typeFilterLevel property BinaryClientFormatterSinkProvider cliFormatter = new BinaryClientFormatterSinkProvider(props, null); BinaryServerFormatterSinkProvider srvFormatter = new BinaryServerFormatterSinkProvider(props, null); // The channel requires these to be set that it can found by name by clients props["name"] = "SyslogConsole"; props["portName"] = "SyslogConsole"; props["authorizedGroup"] = "Everyone"; // Create the channel channel = new IpcChannel(props, cliFormatter, srvFormatter); channel.IsSecured = false; // Register the channel in the Windows IPC list ChannelServices.RegisterChannel(channel, false); // Register the channel for remoting use RemotingConfiguration.RegisterWellKnownServiceType(typeof(ClientMethods), "Server", WellKnownObjectMode.Singleton); // Assign the event to a handler Listener.MessageReceived += new Listener.MessageReceivedEventHandler(Listener_MessageReceived); } catch (Exception ex) { EventLogger.LogEvent("Could not create a named pipe because: " + ex.Message + Environment.NewLine + "Communication with the GUI console will be disabled.", System.Diagnostics.EventLogEntryType.Warning); } }
public frmRCleint() { InitializeComponent(); //************************************* TCP *************************************// // using TCP protocol // running both client and server on same machines //TcpChannel chan = new TcpChannel(); //˫���ŵ� BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 0;//���ն˿�(���) TcpChannel chan = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(chan,false); // Create an instance of the remote object remoteObject = (MyRemotableObject) Activator.GetObject(typeof(MyRemotableObject),"tcp://localhost:8080/HelloWorld"); // if remote object is on another machine the name of the machine should be used instead of localhost. //************************************* TCP *************************************// wrapper = new EventWrapper();//�¼���װ������ wrapper.LocalEvent += new ServerEventHandler(OnServerEvent); remoteObject.ServerEvent += new ServerEventHandler(wrapper.Response); }
private void CreateCommunicationChannel() { BinaryServerFormatterSinkProvider binaryServerProv = new BinaryServerFormatterSinkProvider(); binaryServerProv.TypeFilterLevel = TypeFilterLevel.Full; BinaryClientFormatterSinkProvider binaryClientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = settings.Port; props["authenticationMode"] = "IdentifyCallers"; //HttpChannel chan = new HttpChannel(props, binaryClientProv, binaryServerProv); try { TcpChannel chan = new TcpChannel(props, binaryClientProv, binaryServerProv); ChannelServices.RegisterChannel(chan, false); if (chan == null) { new WindowsServiceLog().WriteEntry( string.Format("Could not start server with port {0}", settings.Port)); Process.GetCurrentProcess().Kill(); } } catch (SocketException e) { new WindowsServiceLog().WriteEntry( string.Format("Could not start server. Application port {1} is using by another application. Error message: {0}", e.Message, settings.Port)); Process.GetCurrentProcess().Kill(); } }
private void btnStart_Click(object sender, EventArgs e) { setServiceXml(); btnStart.Enabled = false; try { Setting.Load(); BinaryServerFormatterSinkProvider binaryServerFormatterSinkProvider = new BinaryServerFormatterSinkProvider(); BinaryClientFormatterSinkProvider clientSinkProvider = new BinaryClientFormatterSinkProvider(); binaryServerFormatterSinkProvider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary dic = new Dictionary<string, int>(); dic.Add("port", Setting.Instance.Port); TcpChannel channel = new TcpChannel(dic, clientSinkProvider, binaryServerFormatterSinkProvider); ChannelServices.RegisterChannel(channel, false); List<IRemoteService> list = ServicesManager.GetTypeFromAssembly<IRemoteService>(); foreach (IRemoteService service in list) { service.RegisterService(); } btnStop.Enabled = true; } catch (Exception ex) { btnStart.Enabled = true; throw ex; } }
private void RegisterRemoting() { { try { BinaryServerFormatterSinkProvider server_provider = new BinaryServerFormatterSinkProvider(); server_provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider client_provider = new BinaryClientFormatterSinkProvider(); IDictionary properties = new Hashtable(); properties["port"] = "0"; TcpChannel channel = new TcpChannel(properties, client_provider, server_provider); ChannelServices.RegisterChannel(channel, false); user = (IUser)Activator.GetObject(typeof(IUser), "tcp://localhost:9998/UserHandeling"); portal = (IPortal)Activator.GetObject(typeof(IPortal), "tcp://localhost:9998/PortalHandeling"); ftserver = (IFTserver)Activator.GetObject(typeof(IFTserver), "tcp://localhost:9998/TransferHandeling"); } catch (RemotingException e) { MessageBox.Show("Connection Error"); } } }
public static void Main(string[] args) { short port=23456; Console.WriteLine("USAGE: subserver <portnumber>"); if(args.Length>1 && Int16.TryParse(args[1],out port) && port>1024){ //OK, got good port } else { port = 23456; //default port } try { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = port; TcpChannel chan = new TcpChannel(props, clientProv, serverProv); //create the tcp channel ChannelServices.RegisterChannel(chan,false); //register the tcp channel RemotingConfiguration.RegisterWellKnownServiceType(typeof(subsharelib.subshareRemoteObject),"SUBSERVER",WellKnownObjectMode.Singleton); //publish the remote object Console.WriteLine("SERVER STARTED AT PORT "+port); } catch (Exception ex) { Console.WriteLine("SERVER CAN NOT START! "+ex); } Console.Write("Press any key to exit . . . "); Console.ReadKey(true); }
public static UserWarehouse GetInstance() { var clientFormatter = new BinaryClientFormatterSinkProvider(); HttpChannel httpChannel = new HttpChannel(null, clientFormatter, null); ChannelServices.RegisterChannel(httpChannel, false); return (UserWarehouse)Activator.GetObject(typeof(UserWarehouse), "http://localhost:5000/UserWarehouse"); }
public static void RegisterRemotingChannel () { IDictionary dict = new Hashtable (); BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); dict ["port"] = 0; serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; ChannelServices.RegisterChannel (new TcpChannel (dict, clientProvider, serverProvider), false); }
private static void SetupRemoting(int port) { BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }; IDictionary props = new Hashtable(); props["port"] = port; Logger.Info("Initializing on port " + port + "..."); TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider); ChannelServices.RegisterChannel(chan, false); }
public static void RegisterRemotingChannel () { IDictionary dict = new Hashtable (); BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); unixRemotingFile = Path.GetTempFileName (); dict ["portName"] = Path.GetFileName (unixRemotingFile); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; ChannelServices.RegisterChannel (new IpcChannel (dict, clientProvider, serverProvider), false); }
public static void Init(int port) { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = port; TcpChannel tcp_channel = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(tcp_channel, false); }
static void Main(string[] args) { Console.WriteLine("Starting client"); BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 0; props["name"] = "clientChannelName"; var channel = new HttpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(channel, false); try { var ctxServer = (IServerContext)RemotingServices.Connect(typeof(IServerContext), "http://localhost:5656" + "/ctxServer"); var ctxClient = new ClientContext(ctxServer, new Execom.IOG.Storage.MemoryStorageUnsafe<Guid, object>()); ConsoleKeyInfo pressedKey = new ConsoleKeyInfo(); do { Console.Clear(); Console.WriteLine("Press ESC to exit"); if (Console.KeyAvailable) { pressedKey = Console.ReadKey(); } if (pressedKey.Key != ConsoleKey.Escape) { using (var ws = ctxClient.OpenWorkspace<Execom.IOG.Distributed.Model.IDataModel>(IsolationLevel.Snapshot)) { for (int i = 0; i < 1000; i++) { var user = ws.New<IUser>(); user.Username = "******"; ws.Data.Users.Add(user); } ws.Commit(); } } } while (pressedKey.Key != ConsoleKey.Escape); } finally { ChannelServices.UnregisterChannel(channel); } }
public void Run(AgentConfig config, bool bDaemonMode) { mConfig = config; // init remoting BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = mConfig.Port; string s = System.Guid.NewGuid().ToString(); props["name"] = s; props["typeFilterLevel"] = TypeFilterLevel.Full; try { TcpChannel chan = new TcpChannel( props, clientProvider, serverProvider); log.InfoFormat("Registering channel on port {0}", mConfig.Port); #if NET_2_0 ChannelServices.RegisterChannel(chan, false); #else ChannelServices.RegisterChannel(chan); #endif } catch (Exception e) { log.InfoFormat("Can't register channel.\n{0}", e.Message); return; } // publish RemotingServices.Marshal(this, PNUnit.Framework.Names.PNUnitAgentServiceName); // otherwise in .NET 2.0 memory grows continuosly FreeMemory(); if (bDaemonMode) { // wait continously while (true) { Thread.Sleep(10000); } } else { Console.ReadLine(); } //RemotingServices.Disconnect(this); }
private void createIpcChannel(IDictionary<string, string> properties) { BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); IDictionary ipcProperties = new Hashtable(); ipcProperties["portName"] = properties["portName"]; ipcProperties["authorizedGroup"] = properties["authorizedGroup"]; ChannelServices.RegisterChannel(new IpcChannel(ipcProperties, clientProvider, serverProvider), false); }
static RemotingPortalClient() { Hashtable properties = new Hashtable(); properties["name"] = "HttpBinary"; BinaryClientFormatterSinkProvider formatter = new BinaryClientFormatterSinkProvider(); HttpChannel channel = new HttpChannel(properties, formatter, null); ChannelServices.RegisterChannel(channel, EncryptChannel); //HttpChannel channel = new HttpChannel(); //ChannelServices.RegisterChannel(channel, EncryptChannel); }
public void Start() { BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider {TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full}; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); IpcChannel ipcCh = new IpcChannel(RemotingConfig.Config, clientProvider, serverProvider); ChannelServices.RegisterChannel(ipcCh, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof (ClientComms), RemotingConfig.ServerName, WellKnownObjectMode.Singleton); }
public static void InitializeRemoting() { var client_provider = new BinaryClientFormatterSinkProvider (); var server_provider = new BinaryServerFormatterSinkProvider (); server_provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; Hashtable props = new Hashtable(); props ["port"] = 0; TcpChannel tcp = new TcpChannel (props, client_provider, server_provider); ChannelServices.RegisterChannel (tcp, false); }
private static void ConnectServer() { var clientProvider = new BinaryClientFormatterSinkProvider(); var serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; var props = new Dictionary<string, object>(); props["port"] = 0; props["name"] = Guid.NewGuid().ToString(); props["typeFilterLevel"] = TypeFilterLevel.Full; var tcpChannel = new TcpChannel(props, clientProvider, serverProvider); ChannelServices.RegisterChannel(tcpChannel, false); }
void CreateConnects() { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); Hashtable ipcProps = new Hashtable(); ipcProps["portName"] = "SysCAD.Service"; //ipcProps["typeFilterLevel"] = TypeFilterLevel.Full; IpcChannel ipcChannel = new IpcChannel(ipcProps, clientProv, serverProv); ChannelServices.RegisterChannel(ipcChannel, false); }
static void SetupTcpChannelWithCustomizedSink() { BinaryServerFormatterSinkProvider server_provider = new BinaryServerFormatterSinkProvider(); server_provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider client_provider = new BinaryClientFormatterSinkProvider(); IDictionary properties = new Hashtable(); properties["port"] = 9998; TcpChannel channel = new TcpChannel(properties, client_provider, server_provider); ChannelServices.RegisterChannel(channel, false); }
private static void StartServer(ServerConfiguration config) { BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }; IDictionary props = new Hashtable(); props["port"] = config.Port; TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider); ChannelServices.RegisterChannel(chan, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(Server), Server.OBJECT_URI, WellKnownObjectMode.Singleton); foreach (var o in RemotingConfiguration.GetRegisteredWellKnownServiceTypes()) { Logger.Info(o.TypeName + " is listening on tcp://localhost:" + config.Port + "/" + o.ObjectUri); } }
private static void ConfigureRemoting() { var server = new BinaryServerFormatterSinkProvider(); server.TypeFilterLevel = TypeFilterLevel.Full; var client = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 0; props["name"] = SERVICENAME; props["typeFilterLevel"] = TypeFilterLevel.Full; ChannelServices.RegisterChannel(new TcpChannel(props, client, null), false); }
/// <summary> /// todoComment /// </summary> /// <param name="ConfigFile"></param> /// <param name="iRemote"></param> public void GetServerConnection(string ConfigFile, out IServerAdminInterface iRemote) { iRemote = null; try { if (TAppSettingsManager.HasValue("Server.Port")) { DetermineServerIPAddress(); IClientChannelSinkProvider TCPSink = new BinaryClientFormatterSinkProvider(); if (TAppSettingsManager.HasValue("Server.ChannelEncryption.PublicKeyfile")) { Hashtable properties = new Hashtable(); properties.Add("FilePublicKeyXml", TAppSettingsManager.GetValue("Server.ChannelEncryption.PublicKeyfile")); TCPSink.Next = new EncryptionClientSinkProvider(properties); } Hashtable ChannelProperties = new Hashtable(); TcpChannel Channel = new TcpChannel(ChannelProperties, TCPSink, null); ChannelServices.RegisterChannel(Channel, false); RemotingConfiguration.RegisterWellKnownClientType( typeof(IServerAdminInterface), String.Format("tcp://{0}:{1}/Servermanager", FServerIPAddr, FServerPort)); } else { RemotingConfiguration.Configure(ConfigFile, false); DetermineServerIPAddress(); } iRemote = (IServerAdminInterface) Activator.GetObject(typeof(IServerAdminInterface), String.Format("tcp://{0}:{1}/Servermanager", FServerIPAddr, FServerPort)); if ((iRemote != null) && (TLogging.DebugLevel > 0)) { TLogging.Log(("GetServerConnection: connected.")); } } catch (Exception exp) { TLogging.Log(("Error in GetServerConnection(), Possible reasons :-" + exp.ToString())); throw; } }
[SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = true)] // demand all rights public static object Connect(string server, string typeName, int serverPort, int clientPort) { BinaryClientFormatterSinkProvider ch = new BinaryClientFormatterSinkProvider(); TcpChannel chan = (TcpChannel)ChannelServices.GetChannel("tcp"); // find TCP-Channel IDictionary prop = new Hashtable(); prop["port"] = clientPort; prop["typeFilterLevel"] = TypeFilterLevel.Full; if (chan == null) // if channel chan is free { chan = new TcpChannel(prop, ch, null); // create new Channel ChannelServices.RegisterChannel(chan, false); // register channel } return Activator.GetObject(typeof(MarshalByRefObject), "tcp://" + server + ":" + serverPort.ToString() + "/" + typeName); // Server-Control-Interface vom Server abfragen }
private void startManagerServer() { Console.WriteLine("Starting Manager "); System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider server_provider = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider(); System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider client_provider = new System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider(); server_provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary prop = new Hashtable(); prop["portName"] = Constants.MANAGER_PORT_NAME; channelManagerServer = new IpcChannel(prop, client_provider, server_provider); ChannelServices.RegisterChannel(channelManagerServer, false); RemotingConfiguration.ApplicationName = /*"ManagerHost"; */ Constants.MANAGER_PORT_NAME + (session_id == null ? "" : "-" + session_id); RemotingConfiguration.RegisterActivatedServiceType(typeof(ManagerObject)); Console.WriteLine("Manager Service " + RemotingConfiguration.ApplicationName + " running ..."); }