Hprose Tcp asp.net c# 如何使用

//server端
     public class HelloClass
        {
            public  string GetHello()
            {
                return "Hello!";
            }
        }
        public  interface IHelloClass
        {
            string GetHello();
            
        } 
    var tcpserver = new HproseTcpListenerServer(string.Format("tcp4://127.0.0.1:4321/", ipPort));
    var newClass = new HelloClass();
    tcpserver.Add(newClass, newClass.GetType(), newClass.GetType().Name);

 

//client端
 string api = "tcp4://127.0.0.1:4321/";
Hprose.Client.HproseClient client = Hprose.Client.HproseClient.Create(api);

 var result1 = client.UseService<IHelloClass>("HelloClass").GetHello();

 

posted @ 2022-03-02 11:18  iDEAAM  阅读(136)  评论(0编辑  收藏  举报