コード例 #1
0
        private static unsafe void BindToInterface(int fd, string interfaceName)
        {
            int idx = GetInterfaceIndex(fd, interfaceName);
            CanSocketAddress addr = new CanSocketAddress();
            addr.can_family = PF_CAN;
            addr.can_ifindex = idx;

            if (-1 == BindSocket(fd, ref addr, (uint)Marshal.SizeOf<CanSocketAddress>()))
            {
                throw new IOException($"Cannot bind to socket to `{interfaceName}`");
            }
        }
コード例 #2
0
ファイル: Interop.cs プロジェクト: JohnXi001/iot-1
 private static extern int BindSocket(int fd, ref CanSocketAddress addr, uint addrlen);