mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
19 lines
417 B
Go
19 lines
417 B
Go
package main
|
|
|
|
import (
|
|
"net"
|
|
"fmt"
|
|
"gitee.com/johng/gf/g/net/gudp"
|
|
)
|
|
|
|
func main() {
|
|
gudp.NewServer(":8999", func(conn *net.UDPConn) {
|
|
var buf [1024]byte
|
|
count, raddr, err := conn.ReadFromUDP(buf[0:])
|
|
if err != nil {
|
|
return
|
|
}
|
|
fmt.Println(raddr.String() + ":", string(buf[0:count]))
|
|
_, err = conn.WriteToUDP([]byte("hi"), raddr)
|
|
}).Run()
|
|
} |