gf/geg/net/tcp_server.go

17 lines
363 B
Go
Raw Normal View History

2017-11-23 10:21:28 +08:00
package main
import (
"net"
"gitee.com/johng/gf/g/net/gtcp"
2017-11-23 10:21:28 +08:00
)
func main() {
gtcp.NewServer(":8999", func(conn net.Conn) {
for {
2018-01-05 17:45:16 +08:00
buffer := make([]byte, 1024)
if length, err := conn.Read(buffer); err == nil {
2018-01-09 10:14:24 +08:00
conn.Write(append([]byte("> "), buffer[0 : length]...))
2017-11-23 10:21:28 +08:00
}
}
}).Run()
}