-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathconnector_test.go
More file actions
49 lines (43 loc) · 810 Bytes
/
connector_test.go
File metadata and controls
49 lines (43 loc) · 810 Bytes
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
48
49
package goev
import (
"fmt"
"runtime"
"strconv"
"sync"
"testing"
)
type Scanner struct {
IOHandle
port int
}
func (s *Scanner) OnOpen() bool {
fmt.Printf("port %d open\n", s.port)
return false
}
func (s *Scanner) OnConnectFail(err error) {
//fmt.Printf("port %d close %s\n", s.port, err.Error())
}
func (s *Scanner) OnClose() {
s.Destroy(s)
}
func TestConnector(t *testing.T) {
fmt.Println("hello boy")
r, err := NewReactor(
EvPollNum(runtime.NumCPU()*2),
TimerHeapInitSize(10000),
)
if err != nil {
panic(err.Error())
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
r.Run()
wg.Done()
}()
c, err := NewConnector(r, SockRcvBufSize(8*1024))
for i := 80; i < 65535; i++ {
c.Connect("108.138.105.100:"+strconv.FormatInt(int64(i), 10), &Scanner{port: i}, 3000)
}
wg.Wait()
}