1
// Copyright 2013 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
13
func (c *genericOpt) sysfd() (syscall.Handle, error) {
14
switch p := c.Conn.(type) {
15
case *net.TCPConn, *net.UDPConn, *net.IPConn:
18
return syscall.InvalidHandle, errInvalidConnType
21
func (c *dgramOpt) sysfd() (syscall.Handle, error) {
22
switch p := c.PacketConn.(type) {
23
case *net.UDPConn, *net.IPConn:
24
return sysfd(p.(net.Conn))
26
return syscall.InvalidHandle, errInvalidConnType
29
func (c *payloadHandler) sysfd() (syscall.Handle, error) {
30
return sysfd(c.PacketConn.(net.Conn))
33
func sysfd(c net.Conn) (syscall.Handle, error) {
34
cv := reflect.ValueOf(c)
35
switch ce := cv.Elem(); ce.Kind() {
37
netfd := ce.FieldByName("conn").FieldByName("fd")
38
switch fe := netfd.Elem(); fe.Kind() {
40
fd := fe.FieldByName("sysfd")
41
return syscall.Handle(fd.Uint()), nil
44
return syscall.InvalidHandle, errInvalidConnType