2019-03-14 08:30:04 +00:00
|
|
|
package tcp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Handler is the TCP Handlers interface
|
|
|
|
type Handler interface {
|
2019-09-13 15:46:04 +00:00
|
|
|
ServeTCP(conn WriteCloser)
|
2019-03-14 08:30:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The HandlerFunc type is an adapter to allow the use of
|
|
|
|
// ordinary functions as handlers.
|
2019-09-13 15:46:04 +00:00
|
|
|
type HandlerFunc func(conn WriteCloser)
|
2019-03-14 08:30:04 +00:00
|
|
|
|
|
|
|
// ServeTCP serves tcp
|
2019-09-13 15:46:04 +00:00
|
|
|
func (f HandlerFunc) ServeTCP(conn WriteCloser) {
|
2019-03-14 08:30:04 +00:00
|
|
|
f(conn)
|
|
|
|
}
|
2019-09-13 15:46:04 +00:00
|
|
|
|
|
|
|
// WriteCloser describes a net.Conn with a CloseWrite method.
|
|
|
|
type WriteCloser interface {
|
|
|
|
net.Conn
|
|
|
|
// CloseWrite on a network connection, indicates that the issuer of the call
|
|
|
|
// has terminated sending on that connection.
|
|
|
|
// It corresponds to sending a FIN packet.
|
|
|
|
CloseWrite() error
|
|
|
|
}
|