fix windows

This commit is contained in:
ffdfgdfg
2019-12-27 23:24:19 +08:00
parent 5e1b0be81c
commit 9b29bd64bd
3 changed files with 73 additions and 23 deletions

View File

@@ -0,0 +1,34 @@
// +build !windows
package mux
import (
"errors"
"net"
"os"
"syscall"
)
func sysGetSock(fd *os.File) (bufferSize int, err error) {
return syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
}
func getConnFd(c net.Conn) (fd *os.File, err error) {
switch c.(type) {
case *net.TCPConn:
fd, err = c.(*net.TCPConn).File()
if err != nil {
return
}
return
case *net.UDPConn:
fd, err = c.(*net.UDPConn).File()
if err != nil {
return
}
return
default:
err = errors.New("mux:unknown conn type, only tcp or kcp")
return
}
}