-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipe_conn_test.go
63 lines (47 loc) · 1.24 KB
/
pipe_conn_test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package watermillnet_test
import (
"net"
"time"
)
type pipeAddr struct{}
func (pa pipeAddr) Network() string { return "pipe" }
func (pa pipeAddr) String() string { return "pipe" }
type PipeConnection struct {
LeftSide net.Conn
RightSide net.Conn
}
func NewPipeConnection() *PipeConnection {
pc := new(PipeConnection)
pc.LeftSide, pc.RightSide = net.Pipe()
return pc
}
func (pc *PipeConnection) RemoteSideConn() net.Conn {
return pc.RightSide
}
func (pc *PipeConnection) Read(b []byte) (n int, err error) {
return pc.LeftSide.Read(b)
}
func (pc *PipeConnection) Write(b []byte) (n int, err error) {
return pc.LeftSide.Write(b)
}
func (pc *PipeConnection) Close() error {
return pc.LeftSide.Close()
}
func (pc *PipeConnection) LocalAddr() net.Addr {
return pc.LeftSide.LocalAddr()
}
func (pc *PipeConnection) RemoteAddr() net.Addr {
return pc.LeftSide.RemoteAddr()
}
func (pc *PipeConnection) SetDeadline(t time.Time) error {
return pc.LeftSide.SetDeadline(t)
}
func (pc *PipeConnection) SetReadDeadline(t time.Time) error {
return pc.LeftSide.SetReadDeadline(t)
}
func (pc *PipeConnection) SetWriteDeadline(t time.Time) error {
return pc.LeftSide.SetWriteDeadline(t)
}
func (pc *PipeConnection) Connect(addr net.Addr) error {
return nil
}