Ejemplo n.º 1
0
        //----------------------

        public int udpBegin(ushort port, ref int socketNumber)
        {
            EthernetUdpNet client = NewUdpClient(ref socketNumber);

            if (client != null)
            {
                return(client.begin(port));
            }

            // all UdpClient sockets used
            setExceptionMessage(new SocketException(10024));
            return(-1);
        }
Ejemplo n.º 2
0
        private bool tryGetUdpClient(int socketNumber, out EthernetUdpNet updClient)
        {
            updClient = null;
            if (socketNumber < 0 || socketNumber >= MAX_UDP_CLIENTS)
            {
                return(false);
            }

            updClient = _udpClients[socketNumber];
            if (updClient == null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public EthernetUdpNet NewUdpClient(ref int socketNumber)
        {
            lock (_udpClients)
            {
                for (int i = 0; i < _udpClients.Length; i++)
                {
                    if (_udpClients[i] == null || !_udpClients[i].Allocated)
                    {
                        if (_udpClients[i] == null)
                        {
                            _udpClients[i] = new EthernetUdpNet();
                        }

                        _udpClients[i].Allocated = true;
                        socketNumber             = i;
                        return(_udpClients[i]);
                    }
                }
            }

            socketNumber = -1;
            return(null);
        }