Giter VIP home page Giter VIP logo

Comments (5)

int2e avatar int2e commented on July 20, 2024

1.需要你提供demo
2.每个独立的server的生成顺序都是从1开始到32或64位int的最大无符号值,然后继续从1开始。

from hpsocket.net.

wphubs avatar wphubs commented on July 20, 2024

Demo.zip

@int2e 你好,这个是DEMO。开启一个Server,两个Client可以复现,不到一分钟会出现shutdown,谢谢。

from hpsocket.net.

int2e avatar int2e commented on July 20, 2024
        public void InitSocketServer(string Address, ushort Port)
        {
             ITcpServer<byte[]>  server = new TcpServer<byte[]>
            {
                Address = Address,
                Port = Port,
                DataReceiveAdapter = new HeadTailDataReceiveAdapter(),
            };
            server.OnPrepareListen += OnPrepareListen;
            server.OnAccept += OnAccept;
            server.OnParseRequestBody += OnParseRequestBody;
            server.OnClose += OnClose;
            server.OnShutdown += OnShutDown;
            server.Start();
        }

改为

 private ITcpServer<byte[]> server = null;
        public void InitSocketServer(string Address, ushort Port)
        {
            server = new TcpServer<byte[]>
            {
                Address = Address,
                Port = Port,
                DataReceiveAdapter = new HeadTailDataReceiveAdapter(),
            };
            server.OnPrepareListen += OnPrepareListen;
            server.OnAccept += OnAccept;
            server.OnParseRequestBody += OnParseRequestBody;
            server.OnClose += OnClose;
            server.OnShutdown += OnShutDown;
            server.Start();
        }

你的问题属于server被gc释放了,不是hpsocket的问题,写法问题,server改为类成员,更正后就好了。

from hpsocket.net.

int2e avatar int2e commented on July 20, 2024

另外注意main函数里的调用,最好两个new的临时对象也改成static 变量 就绝对没有问题了。

from hpsocket.net.

wphubs avatar wphubs commented on July 20, 2024

谢谢大佬指点,之前就是莫名其妙shutdwon,一直没找到原因,原来是GC的问题, 终于搞明白了,非常感谢

from hpsocket.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.