コード例 #1
0
ファイル: IrDAClient.cs プロジェクト: mharasimowicz/pnetlib
        public static IrDADeviceInfo[] DiscoverDevices
            (int maxDevices, Socket irdaSocket)
        {
            // Fetch the option data from the socket.
            int maxSize = 4 + maxDevices * 32;

            byte[] data = irdaSocket.GetSocketOption
                              ((SocketOptionLevel)255, (SocketOptionName)16, maxSize);
            if (data == null || data.Length < 4)
            {
                return(new IrDADeviceInfo [0]);
            }

            // Construct the device array.
            uint num = BitConverter.ToUInt32(data, 0);

            if (num < 0)
            {
                num = 0;
            }
            else if (num > maxDevices)
            {
                num = (uint)maxDevices;
            }
            IrDADeviceInfo[] devs = new IrDADeviceInfo [num];
            int posn;

            for (posn = 0; posn < num; ++posn)
            {
                devs[posn] = new IrDADeviceInfo(data, 4 + posn * 32);
            }
            return(devs);
        }
コード例 #2
0
	public static IrDADeviceInfo[] DiscoverDevices
				(int maxDevices, Socket irdaSocket)
			{
				// Fetch the option data from the socket.
				int maxSize = 4 + maxDevices * 32;
				byte[] data = irdaSocket.GetSocketOption
					((SocketOptionLevel)255, (SocketOptionName)16, maxSize);
				if(data == null || data.Length < 4)
				{
					return new IrDADeviceInfo [0];
				}

				// Construct the device array.
				int num = IrDADeviceInfo.FetchInt32(data, 0);
				if(num < 0)
				{
					num = 0;
				}
				else if(num > maxDevices)
				{
					num = maxDevices;
				}
				IrDADeviceInfo[] devs = new IrDADeviceInfo [num];
				int posn;
				for(posn = 0; posn < num; ++posn)
				{
					devs[posn] = new IrDADeviceInfo(data, 4 + posn * 32);
				}
				return devs;
			}