mirror of
https://gitee.com/johng/gf.git
synced 2024-12-05 05:37:55 +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()
|
|
} |