libp2p / go-reuseport

reuse tcp/udp ports in golang
ISC License
765 stars 108 forks source link

Unexpected address type for UDP #72

Closed gen2brain closed 5 years ago

gen2brain commented 5 years ago

Following example returns an error listen udp 127.0.0.1:1234: address 127.0.0.1:1234: unexpected address type:

package main

import (
    "fmt"
    "os"

    "github.com/libp2p/go-reuseport"
)

func main() {
    l, err := reuseport.Listen("udp", "127.0.0.1:1234")
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    fmt.Println(l)
}
Stebalien commented 5 years ago

You need to use ListenPacket. Listen doesn't support UDP.