Accessing FD (3) for Asterisk EAGI

白昼怎懂夜的黑 提交于 2020-01-14 18:56:24

问题


I have the following Golang code that seems to be blocking indefinitely

eagi := os.NewFile(uintptr(3), "/dev/stdeagi")
data := bufio.NewReaderSize(eagi, 64*1024)
...
data.WriteTo(conn) // Blocks indefinitely!

It doesn't even seem to throw an error - my guess is, I'm accessing the FD incorrectly. My purpose is to access the Process' FD 3 for Asterisk EAGI. I have also tried reading the alternative path fmt.Sprintf("/proc/%d/fd/3", os.Getpid()), but this seems to behave the same way. What am I doing wrong?


回答1:


The right way to do this is syscall.Read(fd int, buf []byte) (n int, err error) (doc). As regards my issue, from inside the Asterisk console, a call to sip show channelstats showed that I wasn't receiving RTP packets altogether, and that the Read was blocking because there really was nothing to read. My networking setup needed work.



来源:https://stackoverflow.com/questions/43353694/accessing-fd-3-for-asterisk-eagi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!