访问Asterisk EAGI的FD(3) [英] Accessing FD (3) for Asterisk EAGI

查看:103
本文介绍了访问Asterisk EAGI的FD(3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下似乎无限期阻塞的Golang代码

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!

它甚至似乎都没有引发错误-我的猜测是,我访问FD的方式不正确.我的目的是访问 Asterisk EAGI 的Process FD 3.我也尝试读取替代路径fmt.Sprintf("/proc/%d/fd/3", os.Getpid()),但这似乎表现出相同的方式.我在做什么错了?

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?

推荐答案

做到这一点的正确方法是syscall.Read(fd int, buf []byte) (n int, err error)(

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.

这篇关于访问Asterisk EAGI的FD(3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆