mirror of https://github.com/EasyDarwin/EasyDarwin
fix pull stream error when url do not contain a port 修改了"timeout"配置不生效的bug 修改了拉流时如果url不含有端口,则不成功的bugpull/132/head
parent
63ca589ebc
commit
09b65d1f61
@ -0,0 +1,25 @@
|
||||
package rtsp
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type RichConn struct {
|
||||
net.Conn
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (conn *RichConn) Read(b []byte) (n int, err error) {
|
||||
if conn.timeout > 0 {
|
||||
conn.Conn.SetReadDeadline(time.Now().Add(conn.timeout))
|
||||
}
|
||||
return conn.Conn.Read(b)
|
||||
}
|
||||
|
||||
func (conn *RichConn) Write(b []byte) (n int, err error) {
|
||||
if conn.timeout > 0 {
|
||||
conn.Conn.SetWriteDeadline(time.Now().Add(conn.timeout))
|
||||
}
|
||||
return conn.Conn.Write(b)
|
||||
}
|
Loading…
Reference in new issue