How to extract a fd using this library?
- 主要语言
- Go
- 星标
- 5.5k
- 派生
- 372
- PR 合并指标
- 30 天内没有已合并 PR
描述
I am trying to keep track of some user state in my application and I would like to get an integer fd of the connection so I can hash and keep track of it in my data structure. I tried below and I get the following error
```
reflect: call of reflect.Value.FieldByName on zero Value
````
having this functionality in the connection struct would really help.
```
netConn := websocket.NetConn(context.Background(), conn, websocket.MessageText)
```
```
func GetFdFromConn(conn net.Conn) int {
tcpConn := reflect.Indirect(reflect.ValueOf(conn)).FieldByName("conn")
fdVal := tcpConn.FieldByName("fd")
pfdVal := reflect.Indirect(fdVal).FieldByName("pfd")
return int(pfdVal.FieldByName("Sysfd").Int())
}
```
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。