GetSocketOption() публичный Метод

public GetSocketOption ( SocketOptionLevel optionLevel, SocketOptionName optionName, int optionLength ) : byte[]
optionLevel SocketOptionLevel
optionName SocketOptionName
optionLength int
Результат byte[]
Пример #1
1
 protected static int SetSocketOption(Socket socket, SocketOptionLevel level, SocketOptionName name, int value)
 {
     if (((int)socket.GetSocketOption(level, name)) == value)
         return value;
     socket.SetSocketOption(level, name, value);
     return (int)socket.GetSocketOption(level, name);
 }
Пример #2
0
        public void Connect(EndPoint endPoint)
        {
            byte[] data = new byte[1024];
            string input, stringData;
            int recv;
            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            int sockopt = (int)server.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout);
            Console.WriteLine("Default timeout: {0}", sockopt);
            server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, _timeout);
            sockopt = (int)server.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout);
            Console.WriteLine("New timeout: {0}", sockopt);

            string welcome = "Hello, are you there?";
            data = Encoding.ASCII.GetBytes(welcome);
            server.SendTo(data, data.Length, SocketFlags.None, endPoint);

            data = new byte[1024];
            try
            {
                Console.WriteLine("Waiting from {0}:", endPoint.ToString());
                recv = server.ReceiveFrom(data, ref endPoint);
                Console.WriteLine("Message received from {0}:", endPoint.ToString());
                Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
            }
            catch (SocketException e)
            {
                if (e.SocketErrorCode == SocketError.HostUnreachable)
                    throw new Exception("CLOSED");
                throw new Exception("TIME_OUT");
            }
            Console.WriteLine("Stopping client");
            server.Close();
        }
Пример #3
0
		protected static bool SetSocketOption(Socket socket, SocketOptionLevel level, SocketOptionName name, bool value) {
			if (((int)socket.GetSocketOption(level, name)) == (value ? 1 : 0))
				return value;
			socket.SetSocketOption(level, name, value);
			if (((int)socket.GetSocketOption(level, name)) != 1) {
				return false;
			}
			return true;
		}
Пример #4
0
        //
        //
        //
        public int ReceiveBytes()
        {
            Array.Clear(_receiveBuffer, 0, _receiveBuffer.Length);

            if (_socket == null)
            {
                throw new SocketException("Socket is null.");
            }

            _socket.Poll(-1, SNS.SelectMode.SelectRead);                // wait until we can read

            // read the 4 byte header that tells us how many bytes we will get
            byte[] readHeader = new byte[4];
            _socket.Receive(readHeader, 0, 4, SNS.SocketFlags.None);

            int bytesToRead = BitConverter.ToInt32(readHeader, 0);
            //Helper.WriteLine( "+++bytesToRead==" + bytesToRead ) ;

            // read the bytes in a loop
            int readBlockSize = (int)_socket.GetSocketOption(SNS.SocketOptionLevel.Socket, SNS.SocketOptionName.ReceiveBuffer);
            //Helper.WriteLine( "+++readBlockSize==" + readBlockSize ) ;

            int bytesReadSoFar = 0;

            while (true)
            {
                int bytesLeftToRead = bytesToRead - bytesReadSoFar;
                if (bytesLeftToRead <= 0)
                {
                    break;                                          // finished receiving
                }
                _socket.Poll(-1, SNS.SelectMode.SelectRead);        // wait until we can read

                // do the read
                int bytesToReadThisTime = Math.Min(readBlockSize, bytesLeftToRead);

                if (bytesToReadThisTime + bytesReadSoFar > SocketConstants.SOCKET_MAX_TRANSFER_BYTES)
                {
                    throw new SocketException("You are trying to read " + bytesToRead + " bytes. Dont read more than " + SocketConstants.SOCKET_MAX_TRANSFER_BYTES + " bytes.");
                }

                int bytesReadThisTime = _socket.Receive(_receiveBuffer, bytesReadSoFar, bytesToReadThisTime, SNS.SocketFlags.None);
                //Helper.WriteLine( "+++bytesReadThisTime==" + bytesReadThisTime ) ;

                bytesReadSoFar += bytesReadThisTime;
            }

            _statsBytesReceived += bytesReadSoFar;              // update stats

            //Helper.WriteLine( "+++finished reading"  ) ;
            return(bytesReadSoFar);
        }
Пример #5
0
        public void setup(Socket listeningSocket)
        {
            /*Pre : client requests a video stream from a server
             *Post: the setup process is begun*/
            try
            {
                //gets dimensions of video player
                dimensions = (int[]) referenceToView.Invoke(referenceToView.getVideoDimensions);
                //creates new IPEndPoint
                IPEndPoint temp = new IPEndPoint((listeningSocket.RemoteEndPoint as IPEndPoint).Address, 6666);
                //stores endpoint
                listenTo = temp as EndPoint;
                //creates UDP socket
                streamSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                //bind it to any IP address on port: 6666
                streamSocket.Bind(bindEP);
                //probably not neccessary
                streamSocket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, BitConverter.GetBytes(10000));

                this.beginStreaming();
            }
            catch (SocketException se)
            {

            }
        }
Пример #6
0
		public PeerCred (Socket sock) {
			if (sock.AddressFamily != AddressFamily.Unix) {
				throw new ArgumentException ("Only Unix sockets are supported", "sock");
			}

			data = (PeerCredData)sock.GetSocketOption (SocketOptionLevel.Socket, (SocketOptionName)so_peercred);
		}
Пример #7
0
 public unsafe _RM_RECEIVER_STATS GetReceiverStats(Socket socket)
 {
     int size = sizeof(_RM_RECEIVER_STATS);
     byte[] data = socket.GetSocketOption(PGM_LEVEL, (SocketOptionName)1013, size);
     fixed (byte* pBytes = &data[0])
     {
         return *((_RM_RECEIVER_STATS*)pBytes);
     }
 }
Пример #8
0
 public unsafe _RM_SEND_WINDOW GetSendWindow(Socket socket)
 {
     int size = sizeof(_RM_SEND_WINDOW);
     byte[] data = socket.GetSocketOption(PgmSocket.PGM_LEVEL, (SocketOptionName)1001, size);
     fixed (byte* pBytes = &data[0])
     {
         return *((_RM_SEND_WINDOW*)pBytes);
     }
 }
Пример #9
0
        public static ClientSocketConfiguration FromSocket(System.Net.Sockets.Socket socket)
        {
            var ep        = socket.RemoteEndPoint as IPEndPoint;
            var keepAlive = socket.GetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.KeepAlive);

            return(new ClientSocketConfiguration
            {
                Hostname = ep.Address.ToString(),
                ServiceName = ep.Port,
                ReceiveBufferSize = socket.ReceiveBufferSize,  // buffer size to use for each socket I/O operation
                KeepAlive = keepAlive != null
            });
        }
Пример #10
0
        //
        // Summary:
        //     Initializes a new instance of the System.Net.Sockets.NetworkStream class
        //     for the specified System.Net.Sockets.Socket with the specified System.Net.Sockets.Socket
        //     ownership.
        //
        // Parameters:
        //   ownsSocket:
        //     true to indicate that the System.Net.Sockets.NetworkStream will take ownership
        //     of the System.Net.Sockets.Socket; otherwise, false.
        //
        //   socket:
        //     The System.Net.Sockets.Socket that the System.Net.Sockets.NetworkStream will
        //     use to send and receive data.
        //
        // Exceptions:
        //   System.IO.IOException:
        //     socket is not connected.-or- The value of the System.Net.Sockets.Socket.SocketType
        //     property of socket is not System.Net.Sockets.SocketType.Stream.-or- socket
        //     is in a nonblocking state.
        //
        //   System.ArgumentNullException:
        //     socket is null.
        public NetworkStream(Socket socket, bool ownsSocket)
        {
            if (socket == null) throw new ArgumentNullException();
            
            // This should throw a SocketException if not connected
            try
            {
                _remoteEndPoint = socket.RemoteEndPoint;
            }
            catch (Exception e)
            {
                int errCode = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Error);

                throw new IOException(errCode.ToString(), e);
            }
            
            // Set the internal socket
            _socket = socket;

            _socketType = (int)_socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Type);

            _ownsSocket = ownsSocket;
        }
Пример #11
0
        private T GetOption <T>(ref T location, ref bool initialized, SocketOptionLevel level, SocketOptionName name)
        {
            // Used in the getter for each shadow property.

            // If we already have our client socket set up, just get its value for the option.
            // Otherwise, return our shadow property.  If that shadow hasn't yet been initialized,
            // first initialize it by creating a temporary socket from which we can obtain a default value.

            if (_clientSocket != null)
            {
                return((T)_clientSocket.GetSocketOption(level, name));
            }

            if (!initialized)
            {
                using (Socket s = CreateSocket())
                {
                    location = (T)s.GetSocketOption(level, name);
                }
                initialized = true;
            }

            return(location);
        }
Пример #12
0
		[Test] // GetSocketOption (SocketOptionLevel, SocketOptionName, Int32)
		public void GetSocketOption3_Socket_Closed ()
		{
			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
			s.Close ();
			try {
				s.GetSocketOption (0, 0, 0);
				Assert.Fail ("#1");
			} catch (ObjectDisposedException ex) {
				// Cannot access a disposed object
				Assert.AreEqual (typeof (ObjectDisposedException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.AreEqual (typeof (Socket).FullName, ex.ObjectName, "#5");
			}
		}
Пример #13
0
		[Test] // GetSocketOption (SocketOptionLevel, SocketOptionName, Byte [])
		public void GetSocketOption2_OptionValue_Null ()
		{
			Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
			try {
				s.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Linger,
					(byte []) null);
				Assert.Fail ("#1");
				} catch (SocketException ex) {
					// The system detected an invalid pointer address in attempting
					// to use a pointer argument in a call
					Assert.AreEqual (typeof (SocketException), ex.GetType (), "#2");
					Assert.AreEqual (10014, ex.ErrorCode, "#3");
					Assert.IsNull (ex.InnerException, "#4");
					Assert.IsNotNull (ex.Message, "#5");
					Assert.AreEqual (10014, ex.NativeErrorCode, "#6");
					Assert.AreEqual (SocketError.Fault, ex.SocketErrorCode, "#7");
				}
		}
Пример #14
0
		/// <summary>
		/// Obtains information about available devices using a socket.
		/// </summary>
		/// <param name="maxDevices">The maximum number of devices to get information about.</param>
		/// <param name="irdaSocket"></param>
		/// <returns></returns>
		public static IrDADeviceInfo[] DiscoverDevices(int maxDevices, Socket irdaSocket)
		{
            if (irdaSocket == null) {
                throw new ArgumentNullException("irdaSocket");
            }
            const int MaxItemsInHugeBuffer = (Int32.MaxValue - 4) / 32;
            if (maxDevices > MaxItemsInHugeBuffer || maxDevices < 0) {
                throw new ArgumentOutOfRangeException("maxDevices");
            }
            //
			byte[] buffer = irdaSocket.GetSocketOption(IrDASocketOptionLevel.IrLmp, IrDASocketOptionName.EnumDevice, 4 + (maxDevices * 32));
            return ParseDeviceList(buffer);
		}
Пример #15
0
 object Utils.Wrappers.Interfaces.ISocket.GetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName)
 {
     return(InternalSocket.GetSocketOption(optionLevel, optionName));
 }
Пример #16
0
        void MCCommReceive()
        {
            var receiveSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            receiveSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false);
            receiveSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            //    receiveSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastLoopback, false);
            IPEndPoint localEP = new IPEndPoint(IPAddress.Any, multicastPort);
            receiveSocket.Bind(localEP);
            var rbuf = receiveSocket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer);

            byte[] multicastAddrBytes = multicastAddr.GetAddressBytes();
            byte[] ipAddrBytes = IPAddress.Any.GetAddressBytes();
            byte[] multicastOpt = new byte[]
            {
               multicastAddrBytes[0], multicastAddrBytes[1], multicastAddrBytes[2], multicastAddrBytes[3],    // WsDiscovery Multicast Address: 239.255.255.250
                 ipAddrBytes       [0], ipAddrBytes       [1], ipAddrBytes       [2], ipAddrBytes       [3]
            };
            receiveSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, multicastOpt);

            //            mySocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastInterface, ipAddrBytes);
            EndPoint senderEP = new IPEndPoint(multicastAddr, multicastPort);
            int len = 0;
            byte[] dataBytes = new byte[RECEIVEBUFSIZE];
            bool mcgJoining = false;
            lock (this)
            {
                joinFlag = true;
                mcgJoining = joinFlag;
            }
            while (mcgJoining)
            {
                try
                {
                    len = receiveSocket.Receive(dataBytes, dataBytes.Length, SocketFlags.None);
                    if (dataBytes[0] == 0xff)
                    {
                        if (dataBytes[1] == 0xfa)
                        {
                            var ackMsgId = new byte[len - 2];
                            Array.Copy(dataBytes, 2, ackMsgId, 0, len - 2);
                            ackWaiting.Set();
                        }
                    }
                    else
                    {
                        len = ((int)(dataBytes[0]) << 8) + dataBytes[1];
                        byte[] buf = new byte[len];
                        for (int i = 0; i < len; i++)
                        {
                            buf[i] = dataBytes[i + 2];
                        }
                        if (OnMulticastMessageReceived != null)
                        {
                            OnMulticastMessageReceived(buf, len, (IPEndPoint)senderEP);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
                lock (this)
                {
                    mcgJoining = joinFlag;
                }
            }

            receiveSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DropMembership, multicastOpt);
        }
Пример #17
0
        public MFTestResults SocketTest1_TCP_SendTimeout()
        {
            ///<summary>
            ///1. Starts a server socket listening for TCP
            ///2. Starts a client socket connected to the server
            ///3. Verifies that data can be correctly sent and recieved
            ///4. Verifies Send timeout is functional
            ///</summary>

            ///skip this test for the emulator since setting socket options is not supported.
            if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)
                return MFTestResults.Skip;

            MFTestResults testResult = MFTestResults.Fail;

            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                int sendTimeout = (int)client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout);
                Log.Comment("Get the SendTimeout size on the server = " + sendTimeout);

                int newTimeout = 1000;
                Log.Comment("Set the receiveTimeout size on the server = " + newTimeout);
                client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, newTimeout);

                int sendTimeout2 = (int)client.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout);
                Log.Comment("The new SendTimeout size on the server=" + sendTimeout2);


                Log.Comment("Testing with port 0");
                client.Bind(new IPEndPoint(IPAddress.Loopback, 0));
                server.Bind(new IPEndPoint(IPAddress.Loopback, 0));

                IPEndPoint epClient = (IPEndPoint)client.LocalEndPoint;
                IPEndPoint epServer = (IPEndPoint)server.LocalEndPoint;

                server.Listen(1);

                client.Connect(epServer);

                using (Socket sock = server.Accept())
                {
                    byte[] recBytes = new byte[12000];

                    Log.Comment("Send to a closed server to cause a timeout.");
                    try
                    {
                        for( int i=0; i<1000; ++i)
                        {
                            int bytesSent = client.Send(recBytes);
                        }
                        Log.Comment("Receiving bytes.");
                        testResult = MFTestResults.Fail;
                    }
                    catch (SocketException e)
                    {
                        Log.Comment("correctly threw exception after Send Timeout on server: " + e);
                        testResult = MFTestResults.Pass;
                    }
                    catch (Exception e)
                    {
                        Log.Comment("incorrectly threw exception: " + e);
                        testResult = MFTestResults.Fail;
                    }
                }
            }
            catch (SocketException e)
            {
                if (e.ErrorCode == (int)SocketError.ProtocolOption)
                {
                    testResult = MFTestResults.Skip;
                }
                else
                {
                    Log.Comment("Caught exception: " + e.Message);
                    Log.Comment("ErrorCode: " + e.ErrorCode.ToString());
                    testResult = MFTestResults.Fail;
                }
            }
            catch (Exception e)
            {
                Log.Comment("Caught exception: " + e.Message);
                testResult = MFTestResults.Fail;
            }
            finally
            {
                server.Close();
                client.Close();
            }
            return testResult;
        }
Пример #18
0
 public static int getSendBufferSize(Socket socket)
 {
     int sz;
     try
     {
         sz = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer);
     }
     catch(SocketException ex)
     {
         closeSocketNoThrow(socket);
         throw new Ice.SocketException(ex);
     }
     return sz;
 }
        protected void ProcessConnect(Socket socket, object state, SocketAsyncEventArgs e)
        {
            if (e != null && e.SocketError != SocketError.Success)
            {
                e.Dispose();
                m_InConnecting = false;
                OnError(new SocketException((int)e.SocketError));
                return;
            }

            if (socket == null)
            {
                m_InConnecting = false;
                OnError(new SocketException((int)SocketError.ConnectionAborted));
                return;
            }

            //To walk around a MonoTouch's issue
            //one user reported in some cases the e.SocketError = SocketError.Succes but the socket is not connected in MonoTouch
            if (!socket.Connected)
            {
                m_InConnecting = false;
#if SILVERLIGHT || NETFX_CORE
                var socketError = SocketError.ConnectionReset;
#else
                var socketError = (SocketError)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Error);
#endif
                OnError(new SocketException((int)socketError));
                return;
            }

            if (e == null)
                e = new SocketAsyncEventArgs();

            e.Completed += SocketEventArgsCompleted;

            Client = socket;

            m_InConnecting = false;

#if !SILVERLIGHT && !NETFX_CORE
            try
            {
                //Set keep alive
                Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
            }
            catch
            {
            }
            
#endif
            OnGetSocket(e);
        }
Пример #20
0
 private void CheckError(int sentBytes, int length, Socket socket)
 {
     // if (sentBytes != length)
     //     _logger.Warn("Not all bytes sent");
     var socketError = (SocketError)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Error);
     if (socketError != SocketError.Success)
     {
         _logger.ErrorFormat("Error on send :  {0}", socketError);
     }
 }
Пример #21
0
 public _RM_RECEIVER_STATS GetReceiverStats(Socket socket)
 {
     int size = Marshal.SizeOf(typeof(_RM_RECEIVER_STATS));
     byte[] data = socket.GetSocketOption(PGM_LEVEL, (SocketOptionName) 1013, size);
     return MarshalHelper.ConvertBytesTo<_RM_RECEIVER_STATS>(data);
 }
Пример #22
0
		public void SocketErrorTest ()
		{
			Socket sock = new Socket (AddressFamily.InterNetwork,
						  SocketType.Stream,
						  ProtocolType.Tcp);
			IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
							BogusPort);
			
			SocketError_event.Reset ();

			sock.Blocking = false;
			sock.BeginConnect (ep, new AsyncCallback(SocketError_callback),
				sock);

			if (SocketError_event.WaitOne (2000, false) == false) {
				Assert.Fail ("SocketError wait timed out");
			}

			Assert.AreEqual (false, sock.Connected, "SocketError #1");

			int error;

			error = (int)sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
			Assert.AreEqual (10061, error, "SocketError #2");

			error = (int)sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
			Assert.AreEqual (10061, error, "SocketError #3");

			sock.Close ();
		}
Пример #23
0
		public void Disposed5 ()
		{
#if TARGET_JVM 
            //UDP sockets are not supported in GH
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
#else
			Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
#endif
			s.Close();

			s.GetSocketOption (0, 0, 0);
		}
Пример #24
0
        //
        // Summary:
        //     Initializes a new instance of the System.Net.Sockets.NetworkStream class
        //     for the specified System.Net.Sockets.Socket with the specified System.Net.Sockets.Socket
        //     ownership.
        //
        // Parameters:
        //   ownsSocket:
        //     true to indicate that the System.Net.Sockets.NetworkStream will take ownership
        //     of the System.Net.Sockets.Socket; otherwise, false.
        //
        //   socket:
        //     The System.Net.Sockets.Socket that the System.Net.Sockets.NetworkStream will
        //     use to send and receive data.
        //
        // Exceptions:
        //   System.IO.IOException:
        //     socket is not connected.-or- The value of the System.Net.Sockets.Socket.SocketType
        //     property of socket is not System.Net.Sockets.SocketType.Stream.-or- socket
        //     is in a nonblocking state.
        //
        //   System.ArgumentNullException:
        //     socket is null.
        internal SocketStream(Socket socket, bool ownsSocket)
        {
            Contract.Requires(socket != null);

            // This should throw a SocketException if not connected
            try
            {
                _remoteEndPoint = socket.RemoteEndPoint;
            }
            catch (Exception e)
            {
                int errCode = (int)socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Error);

                throw new IOException(errCode.ToString(), e);
            }

            // Set the internal socket
            _socket = socket;

            _socketType = (int)_socket.GetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Type);

            _ownsSocket = ownsSocket;
        }
Пример #25
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;
			}