go-examples/echoserver/main.go

27 lines
279 B
Go
Raw Normal View History

2017-07-09 13:15:38 +00:00
package main
import (
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":9000")
if err != nil {
panic(err)
}
defer ln.Close()
for {
conn, err := ln.Accept()
if err != nil {
panic(err)
}
2017-07-09 13:18:24 +00:00
go func() {
io.Copy(conn, conn)
conn.Close()
}()
2017-07-09 13:15:38 +00:00
}
}