iOS NetworkExtension let tunFd = self?.packetFlow.value(forKeyPath: “socket.fileDescriptor“) as! Int

Posted ZH_CQ_iOS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS NetworkExtension let tunFd = self?.packetFlow.value(forKeyPath: “socket.fileDescriptor“) as! Int相关的知识,希望对你有一定的参考价值。

ios进行VPN链接获取tunfd 

iOS15无法正常创建连接,14正常!

解决代码如下

if #available(iOS 15, *)
var buf = [CChar](repeating: 0, count: Int(IFNAMSIZ))
let utunPrefix = "utun".utf8CString.dropLast()
return (0...1024).first (_ fd: Int32) -> Bool in
var len = socklen_t(buf.count)
return getsockopt(fd, 2, 2, &buf, &len) == 0 && buf.starts(with: utunPrefix)

else
return self.packetFlow.value(forKeyPath: "socket.fileDescriptor") as? Int32

以上是关于iOS NetworkExtension let tunFd = self?.packetFlow.value(forKeyPath: “socket.fileDescriptor“) as! Int的主要内容,如果未能解决你的问题,请参考以下文章

iOS NetworkExtension let tunFd = self?.packetFlow.value(forKeyPath: “socket.fileDescriptor“) as! Int

iOS NetworkExtension let tunFd = self?.packetFlow.value(forKeyPath: “socket.fileDescriptor“) as! Int

NetworkExtension - 权利

在 xcode 中添加 NetworkExtension.Framework

NetworkExtension 监控 WiFi 网络变化,即使应用程序未运行

网络扩展 - NE***Manager