Closed sruehl closed 2 years ago
multicast and broadcast http://www.kohala.com/start/mcast.api.txt
the doc of net.ListenUDP excludes multi cast. So not sure if that includes broadcast messages. In that case this PR would be indeed useless...
ok nvm that PR is non-sense, sorry for the inconvenience
for those who find this by google: you can cast the packetCon to a udpCon:
packetConn, err := reuseport.ListenPacket("udp","192.168.178.255:47808")
udpConn := packetConn.(*net.UDPConn)
Hello.
Can you tell us about your use case?
UDP server, which reached limit of using event loop (for { ... sock.ReadFrom(*bytea) ... }
) for incoming datagrams.
How does this work? If I'm listening on the same local address twice, how does the kernel know which listener to deliver the packets to?
Connection for certain protocol (i.e. UDP) identified by tuple of 4 values: src address, src port, dst address, dst port, so if you're listening same endpoint twice with REUSE*, but there are two peers with different src addresses and/or ports, kernel will (well... should) route them to diferrent listeners.
Just FYI, @sruehl's workaround with assertion works fine.
This PR adds support for the ListenUDP function of the net package