예제 #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);