Skip to content

Commit 06a3bcd

Browse files
authored
fix non-blocking mode listening and blocking mode option parsing (#24)
1 parent 9401c69 commit 06a3bcd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

srtgo.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,17 @@ func NewSrtSocket(host string, port uint16, options map[string]string) *SrtSocke
101101
s.pktSize = defaultPacketSize
102102
}
103103

104-
val, s.blocking = options["blocking"]
105-
if !s.blocking || val == "0" {
104+
val, exists = options["blocking"]
105+
if exists && val != "0" {
106+
s.blocking = true
107+
}
108+
if !s.blocking {
106109
s.epollConnect = C.srt_epoll_create()
107110
if s.epollConnect < 0 {
108111
return nil
109112
}
110113
var modes C.int
111-
modes = C.SRT_EPOLL_OUT | C.SRT_EPOLL_ERR
114+
modes = C.SRT_EPOLL_IN | C.SRT_EPOLL_OUT | C.SRT_EPOLL_ERR
112115
if C.srt_epoll_add_usock(s.epollConnect, s.socket, &modes) == SRT_ERROR {
113116
return nil
114117
}
@@ -193,7 +196,7 @@ func (s SrtSocket) Accept() (*SrtSocket, *net.UDPAddr, error) {
193196
len := C.int(2)
194197
timeoutMs := C.int64_t(-1)
195198
ready := [2]C.int{SRT_INVALID_SOCK, SRT_INVALID_SOCK}
196-
if C.srt_epoll_wait(s.epollConnect, nil, nil, &ready[0], &len, timeoutMs, nil, nil, nil, nil) == -1 {
199+
if C.srt_epoll_wait(s.epollConnect, &ready[0], &len, nil, nil, timeoutMs, nil, nil, nil, nil) == -1 {
197200
return nil, nil, fmt.Errorf("srt accept, epoll wait issue")
198201
}
199202
}

0 commit comments

Comments
 (0)