Skip to content

Commit

Permalink
graceful shutdown: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rvflash committed Sep 3, 2019
1 parent d2ebeb4 commit 7dceed7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions example/graceful_server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"log"

"github.com/rvflash/tcp"
)

func main() {
r := tcp.Default()
r.ACK(func(c *tcp.Context) {
// new message received
body, err := c.ReadAll()
if err != nil {
c.Error(err)
return
}
log.Println(string(body))
c.String("read")
})
r.SYN(func(c *tcp.Context) {
c.String("hello")
})
r.FIN(func(c *tcp.Context) {
log.Println("bye")
})
log.Fatal(r.Run(":9090"))
}

0 comments on commit 7dceed7

Please sign in to comment.