static int Main () { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider (); provider.TypeFilterLevel = TypeFilterLevel.Full; Register ("name1", "62000", provider); Register ("name2", "62001", provider); return 0; }
public static void Init() { RemotingConfiguration.Configure(Utils.AppConfigFullPath); //BinaryServerFormatterSinkProvider firstProvider = new BinaryServerFormatterSinkProvider(); //firstProvider.TypeFilterLevel = TypeFilterLevel.Full; IServerChannelSinkProvider firstProvider = new CompressServerChannelSinkProvider(); BinaryServerFormatterSinkProvider sProvider = new BinaryServerFormatterSinkProvider(); sProvider.TypeFilterLevel = TypeFilterLevel.Full; firstProvider.Next = sProvider; TcpServerChannel tcpSvrChannel = new TcpServerChannel("IClient2Server_TCP", ConfigFile.ICS_TcpSvcPort, firstProvider); HttpServerChannel httpSvrChannel = new HttpServerChannel("IClient2Server_HTTP", ConfigFile.ICS_HttpSvcPort, firstProvider); ChannelServices.RegisterChannel(tcpSvrChannel); ChannelServices.RegisterChannel(httpSvrChannel); }
public AddInActivatorClient(string guid, AddInDomainSetup addInDomainSetup) { BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = addInDomainSetup.TypeFilterLevel; BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); Hashtable properties = new Hashtable(); properties[AddInConstants.KeyIpcPortName] = string.Format(AddInActivatorHost.AddInClientChannelNameStringFormat, guid); properties[AddInConstants.KeyIpcChannelName] = string.Format(AddInActivatorHost.AddInClientChannelNameStringFormat, guid); this._ipcChannel = new IpcChannel(properties, clientProvider, serverProvider); ChannelServices.RegisterChannel(this._ipcChannel, false); this._addInActivator = (AddInActivator)Activator.GetObject(typeof(AddInActivator), string.Format(AddInConstants.IpcUrlStringFormat, string.Format(AddInActivatorHost.AddInServerChannelNameStringFormat, guid), AddInActivatorHost.AddInActivatorName)); }
/// <summary> /// Generates and answers a default server sink chain. /// </summary> /// <returns>The first sink provider in the chain.</returns> public static IServerChannelSinkProvider GetDefaultServerSinkChain() { BinaryServerFormatterSinkProvider srv = null; try { // server-side sinks IDictionary sinkProps = new Hashtable(); sinkProps["typeFilterLevel"] = "Full"; srv = new BinaryServerFormatterSinkProvider(sinkProps, null); } catch (Exception) { srv = new BinaryServerFormatterSinkProvider(); } return(srv); }
//setup TCP server channel public void InitializeServerChannel(string name, int port, bool enableSecurity) { RemotingUtils.RemoveChannel(name); var sinkProvider = new BinaryServerFormatterSinkProvider(); sinkProvider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary channelSettings = new Hashtable(); channelSettings["name"] = name; channelSettings["port"] = port; channelSettings["secure"] = enableSecurity; TcpServerChannel channel = new TcpServerChannel(channelSettings, sinkProvider); ChannelServices.RegisterChannel(channel, enableSecurity); }
public void start() { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 0; TcpChannel channel = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(channel, false); IServer server = (IServer)Activator.GetObject(typeof(IServer), "tcp://192.168.19.1:12345/Curse"); var service = new ServiceClient(server); DataContext = new ViewModelLogin(service); }
private void InitializeChannels() { string ChannelName = ChannelName_base + Environment.UserName; var provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; ServerChannel = new IpcServerChannel(ServerName, ChannelName, provider); ChannelServices.RegisterChannel(ServerChannel, false); Server = new JobServerImpl(); RemotingServices.Marshal(Server, ServerName); Server.JobAdded += JobAddedHandler; Server.SoTAdded += SoTAddedHandler; Server.handlersAdded.Set(); // TODO: should we wait until UI has added handlers before setting this? }
public void Start() { //设置反序列化级别 serverProvider = new BinaryServerFormatterSinkProvider(); clientProvider = new BinaryClientFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full;//支持所有类型的反序列化,级别很高 //信道端口 IDictionary idic = new Hashtable(); idic["port"] = _config.LocalPort; idic["name"] = _config.Name; //注册信道 tcpchannel = new TcpChannel(idic, clientProvider, serverProvider); ChannelServices.RegisterChannel(tcpchannel, false); }
private void SetIpcChannel() { // Get SID code for the Built in Administrators group SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null); // Get the NT account related to the SID NTAccount account = sid.Translate(typeof(NTAccount)) as NTAccount; IDictionary sProperties = new Hashtable(); sProperties["portName"] = SvcConfiguration.IpcUriHost; sProperties["authorizedGroup"] = account.Value; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); IpcServerChannel channel = new IpcServerChannel(sProperties, serverProvider); ChannelServices.RegisterChannel(channel, true); }
private static void ConfigureRemoting() { BinaryClientFormatterSinkProvider clientProvider = null; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = 8090; props["typeFilterLevel"] = TypeFilterLevel.Full; TcpChannel chan = new TcpChannel( props, clientProvider, serverProvider); ChannelServices.RegisterChannel(chan); }
public static void CreateService <T>(T serviceInstance, string serviceName, int port) where T : MarshalByRefObject { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = port; props["typeFilterLevel"] = TypeFilterLevel.Full; props["name"] = serviceName; TcpChannel channel = new TcpChannel(props, null, provider); ChannelServices.RegisterChannel(channel, true); RemotingConfiguration.RegisterWellKnownServiceType( serviceInstance.GetType(), serviceName, WellKnownObjectMode.Singleton); }
public TestResultGrp RunTestBinary() { foreach (IChannel channel in ChannelServices.RegisteredChannels) { ChannelServices.UnregisterChannel(channel); } BinaryServerFormatterSinkProvider svr = new BinaryServerFormatterSinkProvider(); BinaryClientFormatterSinkProvider clnt = new BinaryClientFormatterSinkProvider(); HttpChannel httpChannel = new HttpChannel(null, clnt, svr); TcpChannel tcpChannel = new TcpChannel(); ChannelServices.RegisterChannel(httpChannel); ChannelServices.RegisterChannel(tcpChannel); TestResultGrp trg = RunTests(); return(trg); }
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); } }
public ActivatorClient(string guid, ProcessDomainSetup setup) { var serverProvider = new BinaryServerFormatterSinkProvider { TypeFilterLevel = setup.TypeFilterLevel }; var clientProvider = new BinaryClientFormatterSinkProvider(); var properties = new Hashtable(); properties["portName"] = string.Format(ActivatorHost.ClientChannelName, guid); properties["name"] = string.Format(ActivatorHost.ClientChannelName, guid); setup.Remoting.ApplyClientProperties(properties); _channel = new IpcChannel(properties, clientProvider, serverProvider); ChannelServices.RegisterChannel(_channel, false); _activator = (Activator)System.Activator.GetObject(typeof(Activator), string.Format("ipc://{0}/{1}", string.Format(ActivatorHost.ServerChannelName, guid), ActivatorHost.ActivatorName)); }
public void InitEventLogging() { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = PM_SERVICE_PORT; //timeout for puppetMaster responses props["timeout"] = 500; // in milliseconds TcpChannel channel = new TcpChannel(props, null, provider); ChannelServices.RegisterChannel(channel, false); pmLogger = new PMLoggerService(); RemotingServices.Marshal(pmLogger, "PMLogger"); Console.WriteLine("Logger was successfully initialized"); }
public static IpcChannel SetupChannel() { lock (sync) { if (m_hostChannel == null) { var ipcChannelName = Guid.NewGuid().ToString(); var serverSinkProvider = new BinaryServerFormatterSinkProvider(); var clientSinkProvider = new BinaryClientFormatterSinkProvider(); serverSinkProvider.TypeFilterLevel = TypeFilterLevel.Full; var props = new Dictionary <string, string> { { "portName", ipcChannelName } }; m_hostChannel = new IpcChannel(props, clientSinkProvider, serverSinkProvider); ChannelServices.RegisterChannel(m_hostChannel, false); } } return(m_hostChannel); }
public Form() { InitializeComponent(); var prps = new Hashtable { { "name", "" }, { "port", 0 } }; var cProv = new BinaryClientFormatterSinkProvider(); var sProv = new BinaryServerFormatterSinkProvider() { TypeFilterLevel = TypeFilterLevel.Full }; channel = new TcpChannel(prps, cProv, sProv); proxy = new MessageArrivedEventProxy(); proxy.MessageArrivedEvent += new MessageArrived(RecvMessage); }
static void Main(string[] args) { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = TypeFilterLevel.Full; // Creating the IDictionary to set the port on the channel instance. IDictionary props = new Hashtable(); props["port"] = 1111; TcpServerChannel channel = new TcpServerChannel(props, provider); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(PasswordServer.DatabaseInfo), "DatabaseInfo", WellKnownObjectMode.Singleton); Console.ReadLine(); }
public void Run() { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary prop = new Hashtable(); prop["name"] = "pcs"; prop["port"] = this.Uri.Port; TcpChannel channel = new TcpChannel(prop, null, provider); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(OperatorServices), "pcs", WellKnownObjectMode.Singleton); }
/// <summary> /// 启动 /// </summary> public virtual void Start(WellKnownObjectMode mode) { var serverProvider = new BinaryServerFormatterSinkProvider(); var clientProvider = new BinaryClientFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary props = new Hashtable { ["portName"] = string.Format("ServerChannel-Server.{0}", typeof(T).Name) }; serverChannel = new IpcChannel(props, clientProvider, serverProvider); // 注册这个IPC信道. ChannelServices.RegisterChannel(serverChannel, true); // 向信道暴露一个远程对象. RemotingConfiguration.RegisterWellKnownServiceType(typeof(T), "IPCObject", mode); IBusy = true; }
private static TcpChannel CreateTcpChannel(int port, string tcpChannelName) { BinaryServerFormatterSinkProvider serverFormatter = new BinaryServerFormatterSinkProvider(); serverFormatter.TypeFilterLevel = TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); Hashtable props = new Hashtable(); props["port"] = port; props["name"] = tcpChannelName; return(new TcpChannel( props, clientProv, serverFormatter)); }
private void ConfigureRemoting(int port) { if (File.Exists("agent.remoting.conf")) { log.Info("Using agent.remoting.conf"); #if CLR_2_0 || CLR_4_0 RemotingConfiguration.Configure("agent.remoting.conf", false); #else RemotingConfiguration.Configure("agent.remoting.conf"); #endif return; } // init remoting BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; IDictionary props = new Hashtable(); props["port"] = 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}", port); #if CLR_2_0 || CLR_4_0 ChannelServices.RegisterChannel(chan, false); #else ChannelServices.RegisterChannel(chan); #endif } catch (Exception e) { log.InfoFormat("Can't register channel.\n{0}", e.Message); return; } }
static void Main(string[] args) { // Get the configurations int iPortNumber = Int32.Parse(ConfigurationManager.AppSettings["Port"]); string strLogFileName = ConfigurationManager.AppSettings["LogFile"]; // Register a channel try { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = iPortNumber; TcpChannel tcpChannel = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(tcpChannel, true); } catch (RemotingException) { Console.WriteLine("The channel tcp:" + iPortNumber.ToString() + " is already existed!"); return; } catch (Exception) { Console.WriteLine("Register channel tcp:" + iPortNumber.ToString() + " error!"); return; } // Register the remote object try { RemotingConfiguration.ApplicationName = "GalaxyRemoteController"; RemotingConfiguration.RegisterActivatedServiceType(Type.GetType("Galaxy.Tools.RemoteController, RemoteImpLib")); } catch (Exception) { Console.WriteLine("Register remote object error!"); return; } Console.WriteLine("The remote controller service at port:" + iPortNumber.ToString() + " is started successfully."); Console.ReadLine(); }
/// <summary> /// Makes a connection to the service's remoting channel. /// </summary> public void Connect() { if (_isConnected) { return; } try { var props = new Hashtable(); props["typeFilterLevel"] = "Full"; // Both formatters only use the typeFilterLevel property var cliFormatter = new BinaryClientFormatterSinkProvider(props, null); var srvFormatter = new BinaryServerFormatterSinkProvider(props, null); // The channel requires these to be set that it can found by name by the service props["name"] = "ConsoleClient"; props["portName"] = "ConsoleClient"; props["authorizedGroup"] = "Everyone"; // Create the channel _channel = new IpcChannel(props, cliFormatter, srvFormatter); // Register the channel for remoting use ChannelServices.RegisterChannel(_channel, false); // Create the refence to the service's remoting channel _remoter = (ClientMethods)Activator.GetObject(typeof(ClientMethods), "ipc://SyslogConsole/Server"); // Register the MessageReceivedCallback event on the handler RemotingConfiguration.RegisterWellKnownServiceType(typeof(MessageReceivedCallbackSink), "ServerEvents", WellKnownObjectMode.Singleton); // Setup the event subscription _sink = new MessageReceivedSink(); _remoter.MessageHandled += _sink.FireMessageReceived; _isConnected = true; } catch { _isConnected = false; } }
public static void Connect(IMessageListener messageListener) { Timer.Change(0, Timeout.Infinite); if (messageListener == null) { return; } if (string.IsNullOrWhiteSpace(LocalSettings.MessagingServerName)) { return; } _messageListener = messageListener; var serverProv = new BinaryServerFormatterSinkProvider { TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full }; var clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 0; _channel = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(_channel, false); var url = String.Format("tcp://{0}:{1}/ChatServer", LocalSettings.MessagingServerName, LocalSettings.MessagingServerPort); try { _serverObject = (MessagingServerObject)Activator.GetObject(typeof(MessagingServerObject), url); _clientObject = new MessagingClientObject(); _serverObject.Attach(_clientObject); } catch { HandleError(); return; } IsConnected = true; Timer.Change(0, 1000); }
public static CResultAErreur Init(int nPort, string strFactoryURL, string strBindTo) { string strNomChannel = c_nomChannel + "_" + nPort.ToString(); CResultAErreur result = CResultAErreur.True; try { if (ChannelServices.GetChannel(strNomChannel) == null) { //SimmoTech.Utils.Remoting.CustomBinaryServerFormatterSinkProvider serverProv = new SimmoTech.Utils.Remoting.CustomBinaryServerFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); //SimmoTech.Utils.Remoting.CustomBinaryClientFormatterSinkProvider clientProv = new SimmoTech.Utils.Remoting.CustomBinaryClientFormatterSinkProvider(); Hashtable table = new Hashtable(); table["port"] = nPort; table["name"] = strNomChannel; if (strBindTo.Length > 0) { table["bindTo"] = strBindTo; } TcpChannel channel = new TcpChannel(table, clientProv, serverProv); ChannelServices.RegisterChannel(channel); } C2iFactory.InitDefaultUrl(strFactoryURL); //teste que les paramètres sont Ok if (!C2iFactory.TestServeurParDefaut()) { result.EmpileErreur(I.T("The server @1 doesn't answer|105", strFactoryURL)); } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); result.EmpileErreur(I.T("Error while SC2IClient initialization|106")); } return(result); }
public static IChannel GetChannel(int tcpPort, bool isSecure) { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = TypeFilterLevel.Full; IDictionary propBag = new Hashtable(); propBag["port"] = tcpPort; propBag["typeFilterLevel"] = TypeFilterLevel.Full; propBag["name"] = Guid.NewGuid().ToString(); if (isSecure) { propBag["secure"] = isSecure; propBag["impersonate"] = false; } return(new TcpChannel( propBag, null, serverProv)); }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2116:AptcaMethodsShouldOnlyCallAptcaMethods")] // TODO: Microsoft.Scripting does not need to be APTCA internal static IpcChannel CreateChannel(string channelName, string portName) { // The Hosting API classes require TypeFilterLevel.Full to be remoted BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; System.Collections.IDictionary properties = new System.Collections.Hashtable(); properties["name"] = channelName; properties["portName"] = portName; // exclusiveAddressUse corresponds to the FILE_FLAG_FIRST_PIPE_INSTANCE flag of CreateNamedPipe. // Setting it to true seems to cause "Failed to create an IPC Port: Access is denied." occasionally. // TODO: Setting this to false is secure only if we use ACLs as well. properties["exclusiveAddressUse"] = false; // Create the channel. IpcChannel channel = new IpcChannel(properties, null, serverProv); return(channel); }
private static void CreateRemoteService(string channelName) { BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary props = new Dictionary <string, string>(); props["name"] = channelName; props["portName"] = channelName; props["exclusiveAddressUse"] = "false"; channel = new IpcServerChannel(props, serverProvider); ChannelServices.RegisterChannel(channel, true); IPCRemoteService remoteService = new IPCRemoteService(); RemotingServices.Marshal(remoteService, RemoteServiceName); }
public CRemoting() { // // TODO: agregar aquí la lógica del constructor // puerto = CKernel.Preferences.GetInt("RemoteControlPort", 4670); IPPermitida = CKernel.Preferences.GetStringArray("AllowedIP"); Hashtable props = new Hashtable(); props.Add("name", "eAntService"); props.Add("priority", "10"); //en la ayuda pone que son enteros, pero con ellos da error de conversion. props.Add("port", puerto); props.Add("supressChannelData", true); props.Add("useIpAddress", true); props.Add("rejectRemoteRequests", false); #if (!COMPRESSION) BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider(); provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; m_AntChannel = new TcpServerChannel(props, provider); ChannelServices.RegisterChannel(m_AntChannel); #else //Iniciacion Hashtable propsinks = new Hashtable(); propsinks.Add("includeVersions", true); propsinks.Add("typeFilterLevel", "Full"); Hashtable datasinks = new Hashtable(); //2ª Opcion eAntServerSinkProvider provider = new eAntServerSinkProvider(propsinks, datasinks); //Creacion m_AntChannel = new TcpServerChannel(props, provider); ChannelServices.RegisterChannel(m_AntChannel); #endif RemotingConfiguration.RegisterWellKnownServiceType( typeof(CInterfaceGateway), "InterfazRemota", WellKnownObjectMode.Singleton); }
static void Main(string[] args) { PCMemberTests tests = new PCMemberTests(); tests.RunAllTests(); // call all tests RepositoryConference repoConf = new RepositoryConference(); //repoConf.add(new Conference("nume1", DateTime.Now, "ed1")); //repoConf.add(new Conference("nume2", DateTime.Now, "ed1")); //repoConf.add(new Conference("nume3", DateTime.Now, "ed1")); RepositoryArticle repoArticle = new RepositoryArticle(); RepositoryAuthor repoAuthor = new RepositoryAuthor(); RepositoryPCMember repoPCM = new RepositoryPCMember(); RepositorySection repoSection = new RepositorySection(); RepositoryUser repoUser = new RepositoryUser(); RepositoryReviewer repoReviewer = new RepositoryReviewer(); RepositoryParticipant repoParticipant = new RepositoryParticipant(); RepositoryReview repoReview = new RepositoryReview(); var serviceServer = new ServiceServerImpl(repoConf, repoArticle, repoSection, repoUser, repoAuthor, repoPCM, repoReviewer, repoParticipant, repoReview); BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); IDictionary props = new Hashtable(); props["port"] = 55555; TcpChannel channel = new TcpChannel(props, clientProv, serverProv); ChannelServices.RegisterChannel(channel, false); RemotingServices.Marshal(serviceServer, "Conference"); //Controller tests ControllerTest ctrTest = new ControllerTest(); //ctrTest.getConferenceIdFromNameTest(); ctrTest.RunAll(); Console.WriteLine("Server started ..."); Console.WriteLine("Press <enter> to exit..."); Console.ReadLine(); }
static void Main () { BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider (); provider.TypeFilterLevel = TypeFilterLevel.Full; IDictionary props = new Hashtable (); props ["port"] = 5000; props ["name"] = "originalTcpChannel"; TcpChannel channel = new TcpChannel (props, null, provider); #if NET_2_0 ChannelServices.RegisterChannel(channel, false); #else ChannelServices.RegisterChannel (channel); #endif RemotingServices.Marshal (new MyTest (), "Test"); Console.ReadLine (); }
static string RegisterRemotingChannel () { IDictionary dict = new Hashtable (); BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); string unixRemotingFile = Path.GetTempFileName (); dict ["portName"] = Path.GetFileName (unixRemotingFile); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; ChannelServices.RegisterChannel (new IpcChannel (dict, clientProvider, serverProvider), false); return unixRemotingFile; }
/// <summary> /// Access the .NET Remoting server using code. /// </summary> static void RemotingClientByCode() { ///////////////////////////////////////////////////////////////////// // Create and register a channel (TCP channel in this example) that // is used to transport messages across the remoting boundary. // // Properties of the channel IDictionary props = new Hashtable(); props["typeFilterLevel"] = TypeFilterLevel.Full; // Formatters of the messages for delivery BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; // Create a TCP channel TcpChannel tcpChannel = new TcpChannel(props, clientProvider, serverProvider); // Register the TCP channel ChannelServices.RegisterChannel(tcpChannel, true); ///////////////////////////////////////////////////////////////////// // Create a remotable object. // // Create a SingleCall server-activated object SingleCallObject remoteObj = (SingleCallObject)Activator.GetObject( typeof(SingleCallObject), "tcp://localhost:6100/SingleCallService"); // [-or-] a Singleton server-activated object //SingletonObject remoteObj = (SingletonObject)Activator.GetObject( // typeof(SingletonObject), // "tcp://localhost:6100/SingletonService"); // [-or-] a client-activated object //RemotingConfiguration.RegisterActivatedClientType( // typeof(ClientActivatedObject), // "tcp://localhost:6100/RemotingService"); //ClientActivatedObject remoteObj = new ClientActivatedObject(); ///////////////////////////////////////////////////////////////////// // Use the remotable object as if it were a local object. // string remoteType = remoteObj.GetRemoteObjectType(); Console.WriteLine("Call GetRemoteObjectType => {0}", remoteType); Console.WriteLine("The client process and thread: {0}, {1}", GetCurrentProcessId(), GetCurrentThreadId()); uint processId, threadId; remoteObj.GetProcessThreadID(out processId, out threadId); Console.WriteLine("Call GetProcessThreadID => {0} {1}", processId, threadId); Console.WriteLine("Set FloatProperty += {0}", 1.2f); remoteObj.FloatProperty += 1.2f; Console.WriteLine("Get FloatProperty = {0}", remoteObj.FloatProperty); }
private void Init(IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider) { pool = new TcpConnectionPool(); if(clientSinkProvider == null) { this.clientSinkProvider = new BinaryClientFormatterSinkProvider(); this.clientSinkProvider.Next = new TcpClientSinkProvider(pool, timeout); } else { this.clientSinkProvider = clientSinkProvider; IClientChannelSinkProvider provider = clientSinkProvider; while(provider.Next != null) provider = provider.Next; provider.Next = new TcpClientSinkProvider(pool, timeout); } if(serverSinkProvider == null) serverSinkProvider = new BinaryServerFormatterSinkProvider(); try { if(host != null) { if(useIpAddress) host = Dns.GetHostName(); } else if(bindTo != IPAddress.Any) host = bindTo.ToString(); else { IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName()); if(addresses.Length == 0) throw new RemotingException("TCP error: IP address could not be determined for this host!"); host = addresses[0].ToString(); } } catch(SocketException e) { throw new RemotingException("TCP error: DNS error!", e); } channelData = new ChannelDataStore(new string[] { "tcp://" + TcpConnection.ThisMachineID }); for(IServerChannelSinkProvider provider = serverSinkProvider; provider != null; provider = provider.Next) provider.GetChannelData(channelData); IServerChannelSink chain = ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this); serverSink = new TcpServerSink(chain); StartListening(null); }
/// <summary> /// Create the .NET Remoting server using code. /// </summary> static void RemotingServerByCode() { ///////////////////////////////////////////////////////////////////// // Create and register a channel (TCP channel in this example) that // is used to transport messages across the remoting boundary. // // Properties of the channel IDictionary props = new Hashtable(); props["port"] = 6100; // Port of the TCP channel props["typeFilterLevel"] = TypeFilterLevel.Full; // Formatters of the messages for delivery BinaryClientFormatterSinkProvider clientProvider = null; BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); serverProvider.TypeFilterLevel = TypeFilterLevel.Full; // Create a TCP channel TcpChannel tcpChannel = new TcpChannel(props, clientProvider, serverProvider); // Register the TCP channel ChannelServices.RegisterChannel(tcpChannel, true); ///////////////////////////////////////////////////////////////////// // Register the remotable types on the service end as // server-activated types (aka well-known types) or client-activated // types. // // Register RemotingShared.SingleCallObject as a SingleCall server- // activated type. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemotingShared.SingleCallObject),// Server-activated type "SingleCallService", // objectUri WellKnownObjectMode.SingleCall); // SingleCall mode // Register RemotingShared.SingletonObject as a Singleton server- // activated type. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemotingShared.SingletonObject), // Server-activated type "SingletonService", // objectUri WellKnownObjectMode.Singleton); // Singleton mode // Register RemotingShared.ClientActivatedObject as a client- // activated type. RemotingConfiguration.ApplicationName = "RemotingService"; RemotingConfiguration.RegisterActivatedServiceType( typeof(RemotingShared.ClientActivatedObject)); }
static string RegisterRemotingChannel () { IDictionary formatterProps = new Hashtable (); formatterProps ["includeVersions"] = false; formatterProps ["strictBinding"] = false; IDictionary dict = new Hashtable (); BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider(formatterProps, null); BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; // Mono's and .NET's IPC channels have interoperability issues, so use TCP in this case if (CurrentRuntime != ParentRuntime) { // Running Mono on Windows dict ["port"] = 0; dict ["rejectRemoteRequests"] = true; ChannelServices.RegisterChannel (new TcpChannel (dict, clientProvider, serverProvider), false); return null; } else { string unixRemotingFile = Path.GetTempFileName (); dict ["portName"] = Path.GetFileName (unixRemotingFile); ChannelServices.RegisterChannel (new IpcChannel (dict, clientProvider, serverProvider), false); return unixRemotingFile; } }
public static IServerChannelSinkProvider ServerChannelCreateSinkProviderChain( IServerChannelSinkProvider formatterSinkProvider) { if (formatterSinkProvider == null) { // we use MSFT BinaryFormatter by default for maximum compatibility formatterSinkProvider = new BinaryServerFormatterSinkProvider(); } return formatterSinkProvider; }
private void Init(IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider) { if(clientSinkProvider == null) { this.clientSinkProvider = new BinaryClientFormatterSinkProvider(); this.clientSinkProvider.Next = new TcpClientSinkProvider(pool, timeout); } else { this.clientSinkProvider = clientSinkProvider; IClientChannelSinkProvider provider = clientSinkProvider; while(provider.Next != null) provider = provider.Next; provider.Next = new TcpClientSinkProvider(pool, timeout); } if(serverSinkProvider == null) serverSinkProvider = new BinaryServerFormatterSinkProvider(); channelData = new ChannelDataStore(new string[] { "tcp://" + TcpConnection.ThisMachineID }); for(IServerChannelSinkProvider provider = serverSinkProvider; provider != null; provider = provider.Next) provider.GetChannelData(channelData); IServerChannelSink chain = ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this); serverSink = new TcpServerSink(chain); StartListening(null); }