mirror of https://github.com/EasyDarwin/EasyDarwin
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
444 B
26 lines
444 B
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)
|
|
}
|