Esempio n. 1
0
        /// <summary>
        /// Called when a datagram has been sent.
        /// </summary>
        /// <param name="ar">The result of the asynchronous operation.</param>
        private static void SendToCallback(IAsyncResult ar)
        {
            UDPSendToArgs args = ar.AsyncState as UDPSendToArgs;

            try
            {
                if (args != null)
                {
                    int num_bytes = args.Server.m_udpListen.EndSendTo(ar);
                    args.Server.OnSendTo(args.ClientIP, num_bytes);
                }
            }
            catch (Exception e)
            {
                if (args != null)
                {
                    args.Server.Error(null, e);
                }
            }
        }
Esempio n. 2
0
        /// <summary>Called when a datagram has been sent.</summary>
        /// <param name="ar">The result of the asynchronous operation.</param>
        private static void SendToCallback(IAsyncResult ar)
        {
            UDPSendToArgs asyncState = ar.AsyncState as UDPSendToArgs;

            try
            {
                if (asyncState == null)
                {
                    return;
                }
                int num_bytes = asyncState.Server._udpListen.EndSendTo(ar);
                asyncState.Server.OnSendTo(asyncState.ClientIP, num_bytes);
            }
            catch (Exception ex)
            {
                if (asyncState == null)
                {
                    return;
                }
                asyncState.Server.Error((IClient)null, ex);
            }
        }