本文整理汇总了C#中System.Runtime.Remoting.Channels.Tcp.TcpChannel类的典型用法代码示例。如果您正苦于以下问题:C# TcpChannel类的具体用法?C# TcpChannel怎么用?C# TcpChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TcpChannel类属于System.Runtime.Remoting.Channels.Tcp命名空间,在下文中一共展示了TcpChannel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Connect
public void Connect()
{
cmbCompression.SelectedIndex = 4;
chan1 = new TcpChannel(8082);
try
{
//Set the Host IP
if(txtServer.Text != "")
hostIP = txtServer.Text;
//Register the TCP Channel
ChannelServices.RegisterChannel(chan1, false);
chan1.StartListening(null);
castTimer.Enabled = true;
connected = true;
btnConnect.ImageIndex = 2;
btnConnect.Text = "Disconnect";
updatePanel(pnlBottom, true);
updateText(lblMessage, "Connected to " + hostIP + " - " + DateTime.Now);
}
catch (Exception exc)
{
updateText(lblMessage, exc.Message);
}
}
开发者ID:keithloughnane,项目名称:Omnipresent,代码行数:26,代码来源:Client.cs
示例2: RemotingHostServer
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);
}
开发者ID:ajlopez,项目名称:AjTalk,代码行数:32,代码来源:RemotingHostServer.cs
示例3: FixtureSetUp
public virtual void FixtureSetUp()
{
lock (lockObject)
{
if (channel == null)
{
try
{
foreach (IChannel registeredChannel in ChannelServices.RegisteredChannels)
{
if (registeredChannel is TcpChannel)
{
((TcpChannel) registeredChannel).StopListening(null);
}
ChannelServices.UnregisterChannel(registeredChannel);
}
channel = new TcpChannel(8005);
#if !NET_2_0
ChannelServices.RegisterChannel(channel);
#else
ChannelServices.RegisterChannel(channel, false);
#endif
}
catch
{
// ignore duplicate registration exception if it occurs...
}
}
}
}
开发者ID:fuadm,项目名称:spring-net,代码行数:31,代码来源:BaseRemotingTestFixture.cs
示例4: btnStart_Click
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;
}
}
开发者ID:Seamas,项目名称:code-generator,代码行数:30,代码来源:TestServices.cs
示例5: PuppetMasterForm
public PuppetMasterForm()
{
InitializeComponent();
//Inicializations
puppet_master_history_TextBox.Text = "";
dump_history_TextBox.Text = "";
command_TextBox.Text = "";
BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 8400;
props["timeout"] = 200000;
channel = new TcpChannel(props, null, provider);
ChannelServices.RegisterChannel(channel, true);
clients = new Dictionary<string, Tuple<string, ClientInterface>>();
metadataServers = new Dictionary<string, Tuple<string, MetadataServerInterface>>();
dataServers = new Dictionary<string, Tuple<string, DataServerInterface>>();
clientStartPort = 8100;
metadataServerStartPort = 8200;
dataServerStartPort = 8300;
script = null;
}
开发者ID:srps,项目名称:PADI-FS,代码行数:28,代码来源:PuppetMasterForm.cs
示例6: Start
public void Start()
{
channel = new TcpChannel(8081);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharedObject), "DataPool", WellKnownObjectMode.Singleton);
Log.Print("Server has started");
}
开发者ID:AldenSeries,项目名称:TDDP_lab,代码行数:7,代码来源:Server.cs
示例7: RegisterRemoting
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");
}
}
}
开发者ID:Hourani,项目名称:GDS,代码行数:26,代码来源:Login.cs
示例8: OpenConnection
public void OpenConnection()
{
Log.Info("DatabaseProxy.OpenConnection");
// connecting to the remote database
TcpChannel tcpChannel = new TcpChannel();
ChannelServices.RegisterChannel(tcpChannel);
this.db = (PSPEServer.PSPEDatabaseServer)Activator.GetObject(
typeof(PSPEServer.PSPEDatabaseServer), "tcp://localhost:8085/MyDatabase");
if (null == db)
{
Log.Info("Cannot connect to the server");
}
else
{
Log.Info("Internal tx id:" + db.Connect());
}
// enlisting in the transaction
if (null != this.internalRM)
{
throw new Exception("we don't support multiple connections, this is just a sample");
}
internalRM = new InternalRM(db);
internalRM.Enlist();
}
开发者ID:AlanLiu-AI,项目名称:Buzz,代码行数:25,代码来源:Client.cs
示例9: Main
static void Main(string[] args)
{
RemotingConfiguration.Configure(@"../../App.config", true);
KeyValuePair<int, int> idAndPort;
System.Console.WriteLine("Bootstrapping...");
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel, false);
System.Console.WriteLine("Registered Channel @random");
string address = System.IO.File.ReadAllText(@"../../../mServerLocation.dat");
MasterInterface mServer = (MasterInterface)Activator.GetObject(typeof(MasterInterface), address);
idAndPort = mServer.RegisterTransactionalServer(getIP());
System.Console.WriteLine("Registered at Master");
ChannelServices.UnregisterChannel(channel);
System.Console.WriteLine("Unbinding old port");
BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = idAndPort.Value;
channel = new TcpChannel(props, null, provider);
ChannelServices.RegisterChannel(channel, false);
System.Console.WriteLine("Registered Channel @" + idAndPort.Value);
TransactionalServer ts = new TransactionalServer(idAndPort.Key, mServer, "tcp://"+getIP()+":"+idAndPort.Value+"/Server");
RemotingServices.Marshal(ts, "Server", typeof(TransactionalServer));
System.Console.WriteLine("SERVER ON");
System.Console.WriteLine("Server: " + idAndPort.Key + " Port: " + idAndPort.Value + " IP: "+ getIP());
System.Console.ReadLine();
}
开发者ID:ren90,项目名称:PADI-DSTM,代码行数:34,代码来源:Server.cs
示例10: Register
//HANDLER DO FORM
public bool Register(string nick, string port)
{
this.nick = nick;
TcpChannel channel = new TcpChannel(Int32.Parse(port));
ChannelServices.RegisterChannel(channel, true);
ObjClient objClient = new ObjClient(formClient);
RemotingServices.Marshal(objClient,
"IChatClient",
typeof(ObjClient));
string serverUrl = "tcp://localhost:8086/IChatServer";
serverObj = (ObjServer)Activator.GetObject(
typeof(ObjServer), serverUrl);
if (serverObj == null) {
System.Console.WriteLine("Could not locate server");
return false;
}
string clientUrl = "tcp://localhost:" + port + "/IChatClient";
serverObj.Register(nick, clientUrl);
return true;
}
开发者ID:bphenriques,项目名称:PADI-2015,代码行数:28,代码来源:Client.cs
示例11: JoinToChatRoom
private void JoinToChatRoom()
{
if (chan == null && txtName.Text.Trim().Length != 0)
{
chan = new TcpChannel();
ChannelServices.RegisterChannel(chan, false);
// Create an instance of the remote object
objChatWin = new frmChatWin();
objChatWin.remoteObj = (SampleObject)Activator.GetObject(typeof(RemoteBase.SampleObject), txtServerAdd.Text);
if (!objChatWin.remoteObj.JoinToChatRoom(txtName.Text))
{
MessageBox.Show(txtName.Text+ " already joined, please try with different name");
ChannelServices.UnregisterChannel(chan);
chan = null;
objChatWin.Dispose();
return;
}
objChatWin.key = objChatWin.remoteObj.CurrentKeyNo();
objChatWin.yourName= txtName.Text;
this.Hide();
objChatWin.Show();
}
}
开发者ID:AldenSeries,项目名称:TDDP_lab,代码行数:28,代码来源:frmLogin.cs
示例12: Form1
public Form1()
{
InitializeComponent();
PuppetMaster.ctx = this;
TcpChannel channel = new TcpChannel(8090);
ChannelServices.RegisterChannel(channel, true);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(PuppetMaster), "PseudoNodeReg", WellKnownObjectMode.Singleton);
Clients = new List<Node>();
Servers = new List<Node>();
WriteHostDelegate = new WriteHost(WriteHostMethod);
string currentDirectory = Environment.CurrentDirectory;
string[] newDirectory = Regex.Split(currentDirectory, "PuppetMaster");
string strpath = newDirectory[0] + "Scripts"; //Replace("PuppetMaster", "Scripts");
string[] filePaths = Directory.GetFiles(strpath, "*.txt",
SearchOption.AllDirectories);
foreach (string path in filePaths)
listBox1.Items.Add(path);
this.listBox1.MouseDoubleClick += new MouseEventHandler(listBox1_MouseDoubleClick);
//System.DirectoryServices.DirectoryEntry myDE = new
// System.DirectoryServices.DirectoryEntry(strpath);
//tabPage3.Controls.Add(myDE);
// string nameGuid = myDE.Name + myDE.Guid.ToString();
// WriteUserScriptsDelegate = new WriteUserScripts(WriteUserScriptsMethod);
}
开发者ID:afonsomota,项目名称:ProjectoPADI,代码行数:30,代码来源:Form1.cs
示例13: Main
static void Main(string[] args)
{
RemotingConfiguration.ApplicationName = "CallbackRemoting";
// 设置formatter
BinaryServerFormatterSinkProvider formatter = new BinaryServerFormatterSinkProvider();
formatter.TypeFilterLevel = TypeFilterLevel.Full;
// 设置通道名称和端口
IDictionary propertyDic = new Hashtable();
propertyDic["name"] = "CustomTcpChannel";
propertyDic["port"] = 8502;
// 注册通道
IChannel tcpChnl = new TcpChannel(propertyDic, null, formatter);
ChannelServices.RegisterChannel(tcpChnl, false);
// 注册类型
Type t = typeof(Server);
RemotingConfiguration.RegisterWellKnownServiceType(
t, "ServerActivated", WellKnownObjectMode.Singleton);
Console.WriteLine("Server running, model: Singleton\n");
Console.ReadKey();
}
开发者ID:gy09535,项目名称:.netRemoting,代码行数:25,代码来源:Program.cs
示例14: Main
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);
}
开发者ID:souravzzz,项目名称:subshare,代码行数:30,代码来源:Program.cs
示例15: loadRPCServices
private static void loadRPCServices(string[] args)
{
TcpChannel channel;
channel = new TcpChannel(Int32.Parse(args[0]));
ChannelServices.RegisterChannel(channel, true);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ClientToServerServicesObject),
ServicesNames.ClientToServerServicesName,
WellKnownObjectMode.Singleton);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerToServerServicesObject),
ServicesNames.ServerToServerServicesName,
WellKnownObjectMode.Singleton);
_myUri = (((ChannelDataStore)channel.ChannelData).ChannelUris)[0];
_primaryURI = _myUri;
_serverPort = args[0];
_ServerToServerServiceObject = (ServerToServerServicesObject)Activator.GetObject(
typeof(ServerToServerServicesObject),
ServerApp._myUri + "/" + ServicesNames.ServerToServerServicesName);
}
开发者ID:archie,项目名称:sesun,代码行数:25,代码来源:ServerApp.cs
示例16: Cliente
//Construtor
public Cliente()
{
//Definindo que o canal da Conexão remota será TCP
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel, false);
this.LimparJogadorCliente();
}
开发者ID:gilmarsouza,项目名称:Jokenpo_CSharp,代码行数:8,代码来源:Cliente.cs
示例17: Run
public void Run()
{
try
{
tcp = new TcpChannel (0);
Hashtable options = new Hashtable ();
options ["timeout"] = 10000; // 10s
http = new HttpClientChannel (options, null);
ChannelServices.RegisterChannel (tcp);
ChannelServices.RegisterChannel (http);
AppDomain domain = BaseCallTest.CreateDomain ("testdomain_activation");
server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:9433");
RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:9434");
RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:9433/wkoSingleCall1");
RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:9433/wkoSingleton1");
RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:9434/wkoSingleCall2");
RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:9434/wkoSingleton2");
}
catch (Exception ex)
{
Console.WriteLine (ex);
}
}
开发者ID:nlhepler,项目名称:mono,代码行数:28,代码来源:ActivationTests.cs
示例18: SolicitarBilhetePortabilidade
public Portability SolicitarBilhetePortabilidade(Custumer custumer, Acount acount)
{
//[chamando o webservice do módulo Anatel]
Anatel.IAnatel client;
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel);
client = (Anatel.IAnatel)Activator.GetObject(typeof(Anatel.IAnatel), "tcp://localhost:8091/SolicitarPortabilidadeNumerica");
//[obtendo resposta da Anatel para a portabilidade]
RetornoPortabilidade retorno = client.SolicitarPortabilidadeNumerica(custumer);
//[verificar as validacoes retornadas pela anatel]
if (!retorno.CodigoErro.Equals("0"))
{
PortabilidadeFault falha = new PortabilidadeFault();
falha.CodigoErro = retorno.CodigoErro;
falha.DataErro = retorno.DataErro;
falha.Motivo = retorno.Motivo;
throw new FaultException<PortabilidadeFault>(falha);
}
//[obtendo o numero do bilhete da Anatel]
Portability portabilidade = new Portability();
portabilidade.Bilhete = retorno.Bilhete;
return portabilidade;
}
开发者ID:lucashermano,项目名称:TrabalhoDotNet,代码行数:27,代码来源:AptService.cs
示例19: Main
static void Main(string[] config)
{
string cg;
if(config.Length==0)
{
cg = "DefaultCavity";
}
else
{
cg = config[0];
};
Controller controller = new Controller(cg);
// publish the controller to the remoting system
TcpChannel channel = new TcpChannel(controller.config.TCPChannel);
ChannelServices.RegisterChannel(channel, false);
RemotingServices.Marshal(controller, "controller.rem");
// hand over to the controller
controller.Start();
// the application is finishing - close down the remoting channel
//RemotingServices.Disconnect(controller);
//ChannelServices.UnregisterChannel(channel);
}
开发者ID:ColdMatter,项目名称:EDMSuite,代码行数:27,代码来源:Runner.cs
示例20: button1_Click
private void button1_Click(object sender, EventArgs e)
{
try
{
//使用TCP通道得到远程对象
TcpChannel chan1 = new TcpChannel();
ChannelServices.RegisterChannel(chan1);
ISMUser obj1 = (ISMUser)Activator.GetObject(
typeof(ISMUser),
string.Format("tcp://{0}:8085/SMUserService", SMClientSetting.Default.RemotingServerIP));
if (obj1 == null)
{
XtraMessageBox.Show("连接Remoting服务器失败!");
}
//注册
bool ret = obj1.Login("admin", "123456");
if (ret)
{
//获取"litaiyong"用户相关的摄像头的信息
smCameraInfos = obj1.GetCameraInfoByUserName("litaiyong");
}
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.ToString());
}
}
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:29,代码来源:Form1.cs
注:本文中的System.Runtime.Remoting.Channels.Tcp.TcpChannel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论