stream-server/srt/server.go
2023-09-22 14:58:33 +05:00

30 lines
573 B
Go

package srt
import (
"net"
"fmt"
)
// main entry point, no concept of tunnels in UDP so need to implement
// that separately and cannot simply add a max connlimit here like with RTMP
func NewServer(port string) (error) {
l, err := net.ListenPacket("udp", ":" + port)
if err != nil {
return err
}
go start(l)
return nil
}
func start(l net.PacketConn) {
// basic panic logging for debugging mostly
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
}
}()
intake := NewIntake(l, 1) // limit to one concurrent tunnel
for {
intake.Read()
}
}