Coder Social home page Coder Social logo

Comments (4)

xtaci avatar xtaci commented on July 17, 2024

是的

from kcp-go.

GiXuan avatar GiXuan commented on July 17, 2024

改成下面这样总感觉不合适,尤其中间那句s.Close()不注释掉就错,但是注释掉的话,前一个UDPSession又得不到关闭并释放占有的资源。
请问有什么好的解决办法吗?

                var conv uint32
                convValid := false
                if l.fec != nil {
                    isfec := binary.LittleEndian.Uint16(data[4:])
                    if isfec == typeData {
                        conv = binary.LittleEndian.Uint32(data[fecHeaderSizePlus2:])
                        convValid = true
                    }
                } else {
                    conv = binary.LittleEndian.Uint32(data)
                    convValid = true
                }
                if 0 != conv && s.GetConv() != conv {
                  // 下面一句如果不注释掉,会出现在l.sessions中找不到该addr
                  // s.Close()
                  ok = false
                }
                if !ok { // new session
                    if convValid {
                        if s := newUDPSession(conv, l.dataShards, l.parityShards, l, l.conn, from, l.block); s != nil {
                            s.kcpInput(data)
                            l.sessions[addr] = s
                            l.chAccepts <- s
                        } else {
                            log.Println("cannot create session")
                        }
                    }
                } else {
                    s.kcpInput(data)
                }

from kcp-go.

xtaci avatar xtaci commented on July 17, 2024

连接终止是上层keepalive完成的,属于控制信道。

from kcp-go.

GiXuan avatar GiXuan commented on July 17, 2024

请问,如果希望能够同步进行,也就是关闭上一个UDPSession操作完全完成后,再设ok = false,应该怎么做呢?我试了一下,没找到正确方法。总是在Read处抛出errBrokenPipe错误。

from kcp-go.

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.