fix mux kcp connection

This commit is contained in:
ffdfgdfg
2019-12-28 20:40:00 +08:00
parent 813eae1216
commit 1f64715fab
3 changed files with 33 additions and 5 deletions

View File

@@ -4,13 +4,18 @@ package mux
import (
"errors"
"github.com/xtaci/kcp-go"
"net"
"os"
"syscall"
)
func sysGetSock(fd *os.File) (bufferSize int, err error) {
return syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
if fd != nil {
return syscall.GetsockoptInt(int(fd.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF)
} else {
return 1400 * 320, nil
}
}
func getConnFd(c net.Conn) (fd *os.File, err error) {
@@ -27,6 +32,13 @@ func getConnFd(c net.Conn) (fd *os.File, err error) {
return
}
return
case *kcp.UDPSession:
//fd, err = (*net.UDPConn)(unsafe.Pointer(c.(*kcp.UDPSession))).File()
//if err != nil {
// return
//}
// Todo
return
default:
err = errors.New("mux:unknown conn type, only tcp or kcp")
return