2017-04-01 04:19:50 +00:00
|
|
|
package server
|
2017-02-26 05:17:39 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
type oneConnListener struct {
|
|
|
|
conn net.Conn
|
|
|
|
}
|
|
|
|
|
2017-03-22 22:33:09 +00:00
|
|
|
func (l *oneConnListener) Accept() (net.Conn, error) {
|
|
|
|
if l.conn == nil {
|
2020-05-01 05:47:46 +00:00
|
|
|
loginfo.Println("oneConnListener Accept EOF")
|
2017-03-22 22:33:09 +00:00
|
|
|
return nil, io.EOF
|
2017-02-26 05:17:39 +00:00
|
|
|
}
|
2017-03-22 22:33:09 +00:00
|
|
|
|
|
|
|
c := l.conn
|
2017-02-26 05:17:39 +00:00
|
|
|
l.conn = nil
|
|
|
|
loginfo.Println("Accept", c.LocalAddr().String(), c.RemoteAddr().String())
|
2017-03-22 22:33:09 +00:00
|
|
|
return c, nil
|
2017-02-26 05:17:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *oneConnListener) Close() error {
|
2020-05-01 05:47:46 +00:00
|
|
|
loginfo.Println("oneConnListener close")
|
2017-02-26 05:17:39 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *oneConnListener) Addr() net.Addr {
|
2020-05-01 05:47:46 +00:00
|
|
|
loginfo.Println("oneConnLister addr")
|
2017-02-26 05:17:39 +00:00
|
|
|
return nil
|
|
|
|
}
|