evio/examples/echo-server/main.go

25 lines
409 B
Go
Raw Normal View History

2017-07-04 06:39:18 +03:00
package main
import (
2017-10-28 03:01:03 +03:00
"log"
2017-11-02 03:36:35 +03:00
"net"
2017-07-04 06:39:18 +03:00
2017-10-29 00:58:59 +03:00
"github.com/tidwall/evio"
2017-07-04 06:39:18 +03:00
)
func main() {
2017-10-29 00:58:59 +03:00
var events evio.Events
2017-10-28 03:01:03 +03:00
2017-11-02 03:36:35 +03:00
events.Serving = func(wake func(id int) bool, addrs []net.Addr) (action evio.Action) {
2017-10-28 03:01:03 +03:00
log.Print("echo server started on port 5000")
return
}
2017-10-29 00:58:59 +03:00
events.Data = func(id int, in []byte) (out []byte, action evio.Action) {
2017-10-28 03:01:03 +03:00
out = in
return
}
2017-11-02 03:36:35 +03:00
log.Fatal(evio.Serve(events, "tcp://0.0.0.0:5000"))
2017-07-04 06:39:18 +03:00
}