Ejemplo n.º 1
0
        private void ReceivedCallBack(IAsyncResult ar)
        {
            try
            {
                var client = (UdpClient)ar.AsyncState;
                if (ServerStatus == SocketServerStatus.Pause || ServerStatus == SocketServerStatus.Stop)
                {
                    return;
                }

                IPEndPoint remotePoint = null;
                Byte[]     data        = client.EndReceive(ar, ref remotePoint);
                var        eventArgs   = new SocketReceiveEventArgs(remotePoint, data);
                OnReceivedData(eventArgs);
                ContinueReceiveData();
            }
            catch (SocketException e)
            {
                if (e.ErrorCode != 10004)
                {
                    OnSocketError(new SocketErrorEventArgs(LocalEndPoint, e));
                }
            }
            catch (Exception e)
            {
                OnError(new ErrorEventArgs(LocalEndPoint, e));
            }
        }
Ejemplo n.º 2
0
 protected void OnReceivedData(SocketReceiveEventArgs e)
 {
     RaiseEvent(ReceivedData, e);
 }