TcpService服务新增读写超时配置

This commit is contained in:
boyce
2020-12-03 15:45:13 +08:00
parent 9db4a42d10
commit dfba2fbe47
2 changed files with 32 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/duanhf2012/origin/log"
"net"
"sync"
"time"
)
type ConnSet map[net.Conn]struct{}
@@ -138,3 +139,11 @@ func (tcpConn *TCPConn) WriteMsg(args ...[]byte) error {
func (tcpConn *TCPConn) IsConnected() bool {
return tcpConn.closeFlag == false
}
func (tcpConn *TCPConn) SetReadDeadline(d time.Duration) {
tcpConn.conn.SetReadDeadline(time.Now().Add(d))
}
func (tcpConn *TCPConn) SetWriteDeadline(d time.Duration) {
tcpConn.conn.SetWriteDeadline(time.Now().Add(d))
}