Example #1
0
        public RUDPSocket EndAccept(IAsyncResult asyncResult)
        {
            RUDPAcceptIAsyncResult result = asyncResult as RUDPAcceptIAsyncResult;

            result.EndInvoke(true);
            return(result.AcceptedSocket);
        }
Example #2
0
        internal void OnEndAccept(RUDPSocket acceptedSocket)
        {
            RUDPAcceptIAsyncResult result = null;

            Interlocked.Exchange <RUDPAcceptIAsyncResult>(ref result, _asyncResultAccept);
            if (result == null)
            {
                return;
            }

            Interlocked.Exchange <RUDPAcceptIAsyncResult>(ref _asyncResultAccept, null);

            result.AcceptedSocket = acceptedSocket;
            result.ForceAsyncCall = true;
            result.SetAsCompleted(RUDPSocketError.Success, false);
        }
Example #3
0
        public IAsyncResult BeginAccept(AsyncCallback callback, Object state)
        {
            RUDPAcceptIAsyncResult asyncResult = new RUDPAcceptIAsyncResult(this, callback, state);

            Interlocked.Exchange <RUDPAcceptIAsyncResult>(ref _asyncResultAccept, asyncResult);

            //---- Check if we do not already have a socket
            if (_acceptedRUDPSockets.Count > 0)
            {
                RUDPSocket rudp = _acceptedRUDPSockets[0];
                lock (_acceptedRUDPSockets)
                    _acceptedRUDPSockets.RemoveAt(0);

                OnEndAccept(rudp);
            }
            else
            {
                //-- Request an accept
                _physical.BeginAccept(this, callback, state);
            }

            return(asyncResult);
        }
Example #4
0
		public IAsyncResult BeginAccept(AsyncCallback callback, Object state)
		{
			RUDPAcceptIAsyncResult asyncResult = new RUDPAcceptIAsyncResult(this, callback, state);
			Interlocked.Exchange<RUDPAcceptIAsyncResult>(ref _asyncResultAccept, asyncResult);

			//---- Check if we do not already have a socket
			if (_acceptedRUDPSockets.Count > 0)
			{
				RUDPSocket rudp = _acceptedRUDPSockets[0];
				lock (_acceptedRUDPSockets)
					_acceptedRUDPSockets.RemoveAt(0);

				OnEndAccept(rudp);
			}
			else
			{
				//-- Request an accept
				_physical.BeginAccept(this, callback, state);
			}

			return asyncResult;
		}