tcpmachine/examples/ping-pong/pp-server/main.go
2024-11-27 13:32:31 +02:00

22 lines
389 B
Go

package main
import (
"fmt"
"net"
"time"
"git.qowevisa.me/qowevisa/tcpmachine/tcpserver"
)
func main() {
server := tcpserver.CreateServer("127.0.0.1:10000")
server.On("PING", func(args []string, client net.Conn) {
client.Write([]byte("PONG\n"))
})
time.Sleep(time.Second)
err := server.StartServer()
if err != nil {
fmt.Printf("Error: server.StartServer: %v\n", err)
}
}