访问 Asterisk EAGI 的 FD (3)

huangapple go评论74阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年4月12日 02:31:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/43353694.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定