tcpmachine/examples/ping-pong/pp-server/main.go

22 lines
389 B
Go
Raw Normal View History

package main
import (
"fmt"
"net"
"time"
2024-11-27 12:32:31 +01:00
"git.qowevisa.me/qowevisa/tcpmachine/tcpserver"
)
func main() {
2024-10-11 08:24:32 +02:00
server := tcpserver.CreateServer("127.0.0.1:10000")
server.On("PING", func(args []string, client net.Conn) {
client.Write([]byte("PONG\n"))
})
2024-10-11 08:24:32 +02:00
time.Sleep(time.Second)
err := server.StartServer()
if err != nil {
2024-10-11 08:24:32 +02:00
fmt.Printf("Error: server.StartServer: %v\n", err)
}
}