github.com/GuanceCloud/cliutils@v1.1.21/network/ws/epoll.go (about) 1 // Unless explicitly stated otherwise all files in this repository are licensed 2 // under the MIT License. 3 // This product includes software developed at Guance Cloud (https://www.guance.com/). 4 // Copyright 2021-present Guance, Inc. 5 6 package ws 7 8 // See https://github.com/eranyanay/1m-go-websockets/blob/master/4_optimize_gobwas/epoll.go 9 10 import ( 11 "net" 12 "reflect" 13 ) 14 15 func websocketFD(conn net.Conn) int { 16 tcpConn := reflect.Indirect(reflect.ValueOf(conn)).FieldByName("conn") 17 fdVal := tcpConn.FieldByName("fd") 18 pfdVal := reflect.Indirect(fdVal).FieldByName("pfd") 19 20 return int(pfdVal.FieldByName("Sysfd").Int()) 21 }