MCPcopy
hub / github.com/aceld/zinx / ClientJoin

Function ClientJoin

znotify/notify_test.go:72–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func ClientJoin() {
73 t := time.NewTicker(50 * time.Millisecond)
74 i := 10000
75 for {
76 select {
77 case <-t.C:
78 go func(i int) {
79 conn, err := net.Dial("tcp", "127.0.0.1:9991")
80 if err != nil {
81 fmt.Println("net dial err:", err)
82 return
83 }
84 defer conn.Close()
85
86 id := strconv.Itoa(i)
87 dp := zpack.NewDataPack()
88 msg, err := dp.Pack(zpack.NewMsgPackage(1, []byte(id)))
89 if err != nil {
90 return
91 }
92 _, err = conn.Write(msg)
93
94 if err != nil {
95 return
96 }
97 select {}
98 }(i)
99 i++
100 }
101 }
102
103}
104
105func TestAA(t *testing.T) {
106 time.AfterFunc(5*time.Second, func() {

Callers 1

initFunction · 0.85

Calls 5

PackMethod · 0.95
NewDataPackFunction · 0.92
NewMsgPackageFunction · 0.92
CloseMethod · 0.80
WriteMethod · 0.80

Tested by

no test coverage detected