mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 04:37:49 +08:00
16 lines
357 B
Go
16 lines
357 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"gitee.com/johng/gf/g/net/gudp"
|
|
)
|
|
|
|
func main() {
|
|
gudp.NewServer(":8999", func(conn *net.UDPConn) {
|
|
buffer := make([]byte, 1024)
|
|
if length, addr, err := conn.ReadFromUDP(buffer); err == nil {
|
|
fmt.Println(string(buffer[0 : length]), "from", addr.String())
|
|
}
|
|
}).Run()
|
|
} |