Git Product home page Git Product logo

Comments (6)

panjf2000 avatar panjf2000 commented on May 22, 2024

Hi @darinkes
I believe that Go will give priority to the IPv6 when the server supports both IPv4 and IPv6, have you ever tried "udp4"?

from gnet.

darinkes avatar darinkes commented on May 22, 2024

According to tcpdump its an IPv4 connection from 127.0.0.1 to 127.0.0.1.
E.g. listenAddr is "udp://127.0.0.1:5555"
Works fine with net.ListenUDP("udp", listenAddr), which also gives a correct RemoteAddr()

[::7f00:1] is the result of mangled data cause of the bug in eventloop.go

udp4 does not seem to exist:

listen udp4 127.0.0.1:5555: address 127.0.0.1:5555: unexpected address type

from gnet.

panjf2000 avatar panjf2000 commented on May 22, 2024

I've run a test with UDP on my linux server and printed some logs:
image
It seems that everything goes well, so could you make sure that the listenAddr := fmt.Sprintf("udp://%s", this.cfg.Bind) passes the right arguments to gnet?Maybe you print the whole string of it and check it out?

from gnet.

panjf2000 avatar panjf2000 commented on May 22, 2024

BTY, you could update to the latest code of gnet and try it again, let's see whether the issue still exists.

from gnet.

darinkes avatar darinkes commented on May 22, 2024
func (this *Server) OnInitComplete(srv gnet.Server) (action gnet.Action) {
        log.Debugf("Server is listening on %s (multi-cores: %t, loops: %d)", srv.Addr.String(), srv.Multicore, srv.NumLoops)
        return
}

func (this *Server) React(c gnet.Conn) (out []byte, action gnet.Action) {
        log.Debugf("%v -> %v", c.RemoteAddr(), c.LocalAddr())
}

Results in

2019-11-11 15:25:15 [DEBUG] (udp/server): Server is listening on 127.0.0.1:5555 (multi-cores: true, loops: 24)
2019-11-11 15:25:16 [DEBUG] (udp/server): [::7f00:1]:55170 -> 127.0.0.1:5555

I saw you fixed it in master now: ec7bd36 👍
Thats nearly the same fix I also applied in my local gnet checkout and it works.

from gnet.

darinkes avatar darinkes commented on May 22, 2024

checked out master and now it shows

2019-11-11 15:44:00 [DEBUG] (udp/server): 127.0.0.1:44772 -> 127.0.0.1:5555

Thanks for fixing this so quick

from gnet.

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.