(b []byte)
| 68 | } |
| 69 | |
| 70 | func (c *MirrorConn) Read(b []byte) (int, error) { |
| 71 | c.Unlock() |
| 72 | runtime.Gosched() |
| 73 | n, err := c.Conn.Read(b) |
| 74 | c.Lock() // calling c.Lock() before c.Target.Write(), to make sure that this goroutine has the priority to make the next move |
| 75 | if n != 0 { |
| 76 | c.Target.Write(b[:n]) |
| 77 | } |
| 78 | if err != nil { |
| 79 | c.Target.Close() |
| 80 | } |
| 81 | return n, err |
| 82 | } |
| 83 | |
| 84 | func (c *MirrorConn) Write(b []byte) (int, error) { |
| 85 | return 0, fmt.Errorf("Write(%v)", len(b)) |