英文:
Accessing FD (3) for Asterisk EAGI
问题
我有以下的 Golang 代码,似乎会无限期地阻塞:
eagi := os.NewFile(uintptr(3), "/dev/stdeagi")
data := bufio.NewReaderSize(eagi, 64*1024)
...
data.WriteTo(conn) // 无限期地阻塞!
它甚至似乎没有抛出错误 - 我猜测是我错误地访问了文件描述符(FD)。我的目的是访问进程的第 3 个 FD,用于 Asterisk EAGI。我还尝试了读取替代路径 fmt.Sprintf("/proc/%d/fd/3", os.Getpid())
,但它的行为似乎相同。我做错了什么?
英文:
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
得分: 1
正确的方法是使用syscall.Read(fd int, buf []byte) (n int, err error)
(文档)。关于我的问题,从Asterisk控制台内部调用sip show channelstats
显示我根本没有接收到RTP数据包,并且读取操作被阻塞,因为实际上没有可读取的内容。我的网络设置需要改进。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论