Skip to content
high performance dotnet core socket tcp communication components support ssl
Branch: master
Clone or download
Latest commit 7899fe4 Apr 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vs update to 1.2.6.5 Apr 21, 2019
images
samples update to 1.2.6.5 Apr 21, 2019
src/BeetleX update to 1.2.6.5 Apr 21, 2019
.gitignore 优化消息队列的调度器, 优化Socket 的Accept 性能,测试来看要优越于asp,net core Kestrel的Accept,增… Sep 12, 2018
BeetleX.sln
BeetleX.v11.suo no message Sep 6, 2018
LICENSE Create LICENSE Nov 20, 2018
PipeStream.png no message Sep 6, 2018
README.md Update README.md Apr 21, 2019
SaeaPoolTest.zip Add files via upload Dec 4, 2018
UpgradeLog.htm
global.json no message Sep 6, 2018

README.md

BeetleX

high performance dotnet core socket tcp communication components support ssl

Extended Components

Performance testing

Server:E3-1230V2 Bandwidth:10Gb

1K connections

5K connections

10K connections

Create server

     class Program : ServerHandlerBase
    {
        private static IServer server;

        public static void Main(string[] args)
        {
           
            server = SocketFactory.CreateTcpServer<Program>();
            //server.Options.DefaultListen.CertificateFile = "text.pfx";
            //server.Options.DefaultListen.SSL = true;
            //server.Options.DefaultListen.CertificatePassword = "123456";
            server.Open();
            Console.Write(server);
            Console.Read();
        }
        public override void SessionReceive(IServer server, SessionReceiveEventArgs e)
        {
            string name = e.Stream.ToPipeStream().ReadLine();
            Console.WriteLine(name);
            e.Session.Stream.ToPipeStream().WriteLine("hello " + name);
            e.Session.Stream.Flush();
            base.SessionReceive(server, e);
        }
    }

Create client

    class Program
    {
        static void Main(string[] args)
        {
            TcpClient client = SocketFactory.CreateClient<TcpClient>("127.0.0.1", 9090);
            //ssl
            //TcpClient client = SocketFactory.CreateSslClient<TcpClient>("127.0.0.1", 9090, "localhost");
            while (true)
            {
                Console.Write("Enter Name:");
                var line = Console.ReadLine();
                client.Stream.ToPipeStream().WriteLine(line);
                client.Stream.Flush();
                var reader = client.Read();
                line = reader.ToPipeStream().ReadLine();
                Console.WriteLine(line);
            }
            Console.WriteLine("Hello World!");
        }
    }

create async client

    class Program
    {
        static void Main(string[] args)
        {
            AsyncTcpClient client = SocketFactory.CreateClient<AsyncTcpClient>("127.0.0.1", 9090);
            //SSL
            //AsyncTcpClient client = SocketFactory.CreateSslClient<AsyncTcpClient>("127.0.0.1", 9090, "serviceName");
            client.ClientError = (o, e) =>
            {
                Console.WriteLine("client error {0}@{1}", e.Message, e.Error);
            };
            client.Receive = (o, e) =>
            {
                Console.WriteLine(e.Stream.ToPipeStream().ReadLine());
            };
            var pipestream = client.Stream.ToPipeStream();
            pipestream.WriteLine("hello henry");
            client.Stream.Flush();
            Console.Read();
        }
    }
You can’t perform that action at this time.