12345678910111213141516171819202122232425262728293031 |
- package main
- import "net"
- import "time"
- import "fmt"
- import "encoding/binary"
- import "compress/gzip"
- func main() {
- conn, err := net.Dial("tcp", "localhost:7000")
- if err != nil {
- // handle error
- }
- r, _ := gzip.NewReader(conn)
- for {
- var i int64
- var t int64
- err := binary.Read(r, binary.LittleEndian, &i)
- if err != nil {
- fmt.Println(err)
- return
- }
- err = binary.Read(r, binary.LittleEndian, &t)
- if err != nil {
- fmt.Println(err)
- return
- }
- dt := time.Now().UnixNano() - t
- fmt.Println(i, time.Duration(dt))
- }
- }
|