mirror of
https://github.com/impact-eintr/netstack.git
synced 2025-10-05 12:56:55 +08:00
30 lines
426 B
Go
30 lines
426 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
go func() {
|
|
conn, err := net.Dial("tcp", "192.168.1.1:9999")
|
|
if err != nil {
|
|
fmt.Println("err : ", err)
|
|
return
|
|
}
|
|
log.Println("连接建立")
|
|
conn.Write([]byte("helloworld"))
|
|
log.Println("发送了数据")
|
|
conn.Close()
|
|
}()
|
|
|
|
t := time.NewTimer(1000 * time.Millisecond)
|
|
select {
|
|
case <-t.C:
|
|
return
|
|
}
|
|
|
|
}
|