Esempio n. 1
0
 private void LoadSocketServer()
 {
     SockServConfig = new SockServBuilder(Container, p =>
     {
         return(new ZYSocket.Server.ZYSocketSuper(p));
     });
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     using (var build = new SockServBuilder(p =>
     {
         return(new ZYSocket.Server.ZYSocketSuper(p)
         {
             BinaryInput = new ZYSocket.Server.BinaryInputHandler(BinaryInputHandler),
             MessageInput = new ZYSocket.Server.DisconnectHandler(DisconnectHandler),
             Connetions = new ZYSocket.Server.ConnectionFilter(ConnectionFilter)
         });
     }).ConfigServer(p => p.Port = 3000))
     {
         build.Bulid().Start();
         Console.ReadLine();
     }
 }
Esempio n. 3
0
        //程序入口
        static void Main(string[] args)
        {
            var server = new SockServBuilder(p =>
            {
                return(new ZYSocketSuper(p)
                {
                    BinaryInput = new BinaryInputHandler(BinaryInputHandler),
                    Connetions = new ConnectionFilter(ConnectionFilter),
                    MessageInput = new DisconnectHandler(DisconnectHandler)
                });
            }).Bulid();

            server.Start(); //启动服务器 1000端口


            var server2 = new SockServBuilder(p =>
            {
                return(new ZYSocketSuper(p)
                {
                    BinaryInput = new BinaryInputHandler(BinaryInputHandler),
                    Connetions = new ConnectionFilter(ConnectionFilter),
                    MessageInput = new DisconnectHandler(DisconnectHandler)
                });
            })

                          .ConfigServer(p =>
            {
                p.Host = "ipv6any";
                p.Port = 1001;
            })
                          .Bulid();

            server2.Start(); //启动服务器 所有IPV6 1001端口



            var containerBuilder = new ServiceCollection();

            new SockServBuilder(containerBuilder, p =>
            {
                return(new ZYSocketSuper(p)
                {
                    BinaryInput = new BinaryInputHandler(BinaryInputHandler),
                    Connetions = new ConnectionFilter(ConnectionFilter),
                    MessageInput = new DisconnectHandler(DisconnectHandler)
                });
            })
            .ConfigServer(p => {
                p.Port          = 1002;
                p.MaxBufferSize = 8192;
            });

            var build = containerBuilder.BuildServiceProvider();

            var server3 = build.GetRequiredService <ISocketServer>();

            server3.Start(); //启动服务器 1002端口 缓冲区为8KB


            Console.ReadLine();
            build.Dispose();
            Console.ReadLine();
        }