mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
TcpService服务新增读写超时配置
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user