mirror of https://github.com/EasyDarwin/EasyDarwin
Browse Source
fix pull stream error when url do not contain a port 修改了"timeout"配置不生效的bug 修改了拉流时如果url不含有端口,则不成功的bugpull/132/head
macbookpro
6 years ago
4 changed files with 59 additions and 14 deletions
@ -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