You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
889 B

  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. //"encoding/hex"
  6. . "github.com/tendermint/go-common"
  7. "github.com/tendermint/tmsp/types"
  8. )
  9. func main() {
  10. conn, err := Connect("unix://test.sock")
  11. if err != nil {
  12. Exit(err.Error())
  13. }
  14. // Read a bunch of responses
  15. go func() {
  16. counter := 0
  17. for {
  18. var res = &types.Response{}
  19. err := types.ReadMessage(conn, res)
  20. if err != nil {
  21. Exit(err.Error())
  22. }
  23. counter += 1
  24. if counter%1000 == 0 {
  25. fmt.Println("Read", counter)
  26. }
  27. }
  28. }()
  29. // Write a bunch of requests
  30. counter := 0
  31. for i := 0; ; i++ {
  32. var bufWriter = bufio.NewWriter(conn)
  33. var req = types.RequestEcho("foobar")
  34. err := types.WriteMessage(req, bufWriter)
  35. if err != nil {
  36. Exit(err.Error())
  37. }
  38. err = bufWriter.Flush()
  39. if err != nil {
  40. Exit(err.Error())
  41. }
  42. counter += 1
  43. if counter%1000 == 0 {
  44. fmt.Println("Write", counter)
  45. }
  46. }
  47. }