/* * Copyright (c) 2005 Erik Tigerholm * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ namespace OpenTraffic { using System; using System.Collections; using System.Text; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Runtime.Remoting.Channels.Http; using System.Net; using System.Security.Principal; public class ClientAuthorized : IAuthorizeRemotingConnection { public bool IsConnectingEndPointAuthorized(EndPoint endPoint) { return true; } public bool IsConnectingIdentityAuthorized(IIdentity identity) { return true; } } class Client { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] static int Main(string[] args) { if (args.Length == 0) { args = new string[1]; args[0] = "6665"; // args[1] = "6666"; } // const int nClients = 2; foreach (string portStr in args) { int port = int.Parse(portStr); Console.WriteLine("Starting client 0.6c"); // int port = 6665 + i; Hashtable props = new Hashtable(); props["name"] = "OpenTrafficChannel_" + port; props["port"] = port; // props["impersonate"] = true; props["secure"] = false; // xxx mono patch // TcpServerChannel channel = new TcpServerChannel(props, new BinaryServerFormatterSinkProvider(), new ClientAuthorized()); TcpServerChannel channel = new TcpServerChannel(props, new BinaryServerFormatterSinkProvider()); ChannelServices.RegisterChannel(channel, false); Network.Client client = new Network.Client(port); RemotingServices.Marshal(client, "client" + port + ".rem"); } return 0; } } }