代码之家  ›  专栏  ›  技术社区  ›  divyanshm

在dotnet(c#)中使用netlink连接器?

  •  1
  • divyanshm  · 技术社区  · 7 年前

    netlink connector 侦听进程分叉事件。

    1 回复  |  直到 7 年前
        1
  •  0
  •   divyanshm    7 年前

    看起来您无法使用dotnet创建netlink连接器套接字。System.Net.Sockets不支持基础协议系列和地址系列,尝试向枚举键入强制转换int也无法使用套接字构造函数引发不受支持的地址系列错误。

    #include <linux/connector.h>
    #include <linux/netlink.h>
    #include <sys/socket.h>
    
    int main() {
        int sock = socket(16, SOCK_DGRAM, 11);
        return 0;
    }
    

    但这失败了

    const UInt16 NETLINK_CONNECTOR = 11;
    const UInt16 PF_NETLINK = 16;
    Socket temp = new Socket((AddressFamily)PF_NETLINK, SocketType.Dgram, (ProtocolType)NETLINK_CONNECTOR);
    

    未处理的异常:System.Net.Sockets.SocketException:地址

    以下是corefx回购协议跟踪此功能的github问题- https://github.com/dotnet/corefx/issues/34015