mirror of
https://github.com/aler9/gortsplib
synced 2025-12-24 13:38:08 +08:00
this allows to obtain the underlying net.Listener
This commit is contained in:
@@ -362,6 +362,11 @@ func (s *Server) Wait() error {
|
||||
return s.closeError
|
||||
}
|
||||
|
||||
// NetListener returns the underlying net.Listener
|
||||
func (s *Server) NetListener() net.Listener {
|
||||
return s.tcpListener.ln
|
||||
}
|
||||
|
||||
func (s *Server) run() {
|
||||
defer s.wg.Done()
|
||||
|
||||
|
||||
@@ -240,6 +240,20 @@ func TestServerClose(t *testing.T) {
|
||||
s.Close()
|
||||
}
|
||||
|
||||
func TestServerNetListener(t *testing.T) {
|
||||
s := &Server{
|
||||
Handler: &testServerHandler{},
|
||||
RTSPAddress: "127.0.0.1:8554",
|
||||
}
|
||||
|
||||
err := s.Start()
|
||||
require.NoError(t, err)
|
||||
defer s.Close()
|
||||
|
||||
ln := s.NetListener()
|
||||
require.Equal(t, "127.0.0.1:8554", ln.Addr().String())
|
||||
}
|
||||
|
||||
func TestServerErrorInvalidUDPPorts(t *testing.T) {
|
||||
t.Run("non consecutive", func(t *testing.T) {
|
||||
s := &Server{
|
||||
|
||||
Reference in New Issue
Block a user