-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconn.go
62 lines (46 loc) · 954 Bytes
/
conn.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
package main
import (
"net"
"time"
)
var noAddr *NoAddr = NewNoAddr()
type ErrorConn struct {
}
type NoAddr struct {
}
func NewNoAddr() *NoAddr {
return &NoAddr{}
}
func (n *NoAddr) Network() string {
return "No network"
}
func (n *NoAddr) String() string {
return "No addr"
}
func NewErrorConn() *ErrorConn {
return &ErrorConn{}
}
func (e *ErrorConn) Read(b []byte) (int, error) {
return 0, notConnectedError
}
func (e *ErrorConn) Write(b []byte) (int, error) {
return 0, notConnectedError
}
func (e *ErrorConn) Close() error {
return notConnectedError
}
func (e *ErrorConn) LocalAddr() net.Addr {
return noAddr
}
func (e *ErrorConn) RemoteAddr() net.Addr {
return noAddr
}
func (e *ErrorConn) SetDeadline(t time.Time) error {
return notConnectedError
}
func (e *ErrorConn) SetReadDeadline(t time.Time) error {
return notConnectedError
}
func (e *ErrorConn) SetWriteDeadline(t time.Time) error {
return notConnectedError
}