forked from go/golangs_learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
407 B
30 lines
407 B
package main
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
listener, err := net.Listen("tcp", "172.17.223.103:8000")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
for {
|
|
conn, err := listener.Accept()
|
|
if err != nil {
|
|
log.Print(err)
|
|
continue
|
|
}
|
|
defer conn.Close()
|
|
for {
|
|
_, err := io.WriteString(conn, "hello tcp")
|
|
if err != nil {
|
|
return
|
|
}
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
}
|
|
}
|
|
|