mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 11:48:09 +08:00
24 lines
280 B
Go
24 lines
280 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
conn, err := net.Dial("udp", "127.0.0.1:8999")
|
|
defer conn.Close()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
|
|
conn.Write([]byte("Hello world!"))
|
|
|
|
buffer := make([]byte, 100)
|
|
|
|
conn.Read(buffer)
|
|
|
|
fmt.Println(string(buffer))
|
|
}
|