23 lines
326 B
Go
23 lines
326 B
Go
|
package connection
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
const defaultBufSize = 1 * 1024
|
||
|
|
||
|
|
||
|
// Connection represents a recv-only network connection.
|
||
|
type Connection struct {
|
||
|
BufSize int
|
||
|
conn *net.TCPConn
|
||
|
dataChan chan []byte
|
||
|
stopFlag bool
|
||
|
}
|
||
|
|
||
|
// Close closes the connection
|
||
|
func (c *Connection) Close() {
|
||
|
c.stopFlag = true
|
||
|
c.conn.Close()
|
||
|
}
|