1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-19 02:03:38 -04:00
v2fly/transport/internet/socket_activation_unix.go
2024-09-05 20:55:24 +01:00

23 lines
462 B
Go

//go:build unix
// +build unix
package internet
import (
"os"
"strconv"
"syscall"
"github.com/v2fly/v2ray-core/v5/common/net"
)
func activate_socket(address string) (net.Listener, error) {
fd, err := strconv.Atoi(address[8:])
if err != nil {
return nil, err
}
// Ignore the fail of SetNonblock: it's merely an optimization so that Go can poll this fd.
_ = syscall.SetNonblock(fd, true)
return net.FileListener(os.NewFile(uintptr(fd), address))
}