1 package pipe
2 3 import (
4 "fmt"
5 "io"
6 "net"
7 "runtime"
8 "time"
9 10 "github.com/p9c/p9/pkg/qu"
11 )
12 13 type StdConn struct {
14 io.ReadCloser
15 io.WriteCloser
16 Quit qu.C
17 }
18 19 func New(in io.ReadCloser, out io.WriteCloser, quit qu.C) (s *StdConn) {
20 s = &StdConn{in, out, quit}
21 _, file, line, _ := runtime.Caller(1)
22 o := fmt.Sprintf("%s:%d", file, line)
23 T.Ln("new StdConn at", o)
24 return
25 }
26 27 func (s *StdConn) Read(b []byte) (n int, e error) {
28 return s.ReadCloser.Read(b)
29 }
30 31 func (s *StdConn) Write(b []byte) (n int, e error) {
32 return s.WriteCloser.Write(b)
33 }
34 35 func (s *StdConn) Close() (e error) {
36 s.Quit.Q()
37 return
38 }
39 40 func (s *StdConn) LocalAddr() (addr net.Addr) {
41 // this is a no-op as it is not relevant to the type of connection
42 return
43 }
44 45 func (s *StdConn) RemoteAddr() (addr net.Addr) {
46 // this is a no-op as it is not relevant to the type of connection
47 return
48 }
49 50 func (s *StdConn) SetDeadline(t time.Time) (e error) {
51 // this is a no-op as it is not relevant to the type of connection
52 return
53 }
54 55 func (s *StdConn) SetReadDeadline(t time.Time) (e error) {
56 // this is a no-op as it is not relevant to the type of connection
57 return
58 }
59 60 func (s *StdConn) SetWriteDeadline(t time.Time) (e error) {
61 // this is a no-op as it is not relevant to the type of connection
62 return
63 }
64