Remoting服务器

[c-sharp]  view plain  copy
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Text;  
  7. using System.Windows.Forms;  
  8. using System.Runtime;  
  9. using System.Runtime.Remoting;  
  10. using System.Runtime.Remoting.Channels;  
  11. using System.Runtime.Remoting.Channels.Http;  
  12.   
  13. namespace RemotingXPServer  
  14. {  
  15.     public partial class Form1 : Form  
  16.     {  
  17.         HttpChannel http = new HttpChannel(10096);  
  18.   
  19.         public Form1()  
  20.         {  
  21.             InitializeComponent();  
  22.         }  
  23.   
  24.         private void btnStartServer_Click(object sender, EventArgs e)  
  25.         {  
  26.             ChannelServices.RegisterChannel(http, false);  
  27.             RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloRemoting.Hello), "Hi", WellKnownObjectMode.SingleCall);  
  28.             MessageBox.Show("服务已经打开,点击确定关闭服务");  
  29.             this.btnStartServer.Enabled = false;  
  30.             this.btnClose.Enabled = true;              
  31.         }  
  32.   
  33.         private void btnClose_Click(object sender, EventArgs e)  
  34.         {  
  35.             ChannelServices.UnregisterChannel(http);  
  36.             this.btnStartServer.Enabled = true;  
  37.             this.btnClose.Enabled = false;  
  38.         }  
  39.   
  40.     }  
  41. }  
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值