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 {
|
|
|
|
loginfo.Println("Accept EOF")
|
|
|
|
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 {
|
|
|
|
loginfo.Println("close")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *oneConnListener) Addr() net.Addr {
|
|
|
|
loginfo.Println("addr")
|
|
|
|
return nil
|
|
|
|
}
|