-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (39 loc) · 794 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"time"
"github.com/ipoluianov/xchg/xchg"
"github.com/ipoluianov/xchg/xchg_samples"
)
func main() {
count := 0
errs := 0
fn := func() {
serverPrivateKey, _ := xchg.GenerateRSAKey()
server := xchg_samples.NewSimpleServer(serverPrivateKey)
server.Start()
serverAddress := xchg.AddressForPublicKey(&serverPrivateKey.PublicKey)
fmt.Println(serverAddress)
client := xchg_samples.NewSimpleClient(serverAddress)
for {
time.Sleep(3000 * time.Millisecond)
var err error
_, err = client.Version()
if err != nil {
errs++
} else {
count++
}
}
}
for i := 0; i < 1; i++ {
go fn()
time.Sleep(100 * time.Millisecond)
}
for {
time.Sleep(1 * time.Second)
fmt.Println("res:", count, errs)
count = 0
errs = 0
}
}