Exemple #1
0
 private void OnDataSent(PacketDataSentEventArgs e)
 {
     if (this.DataSent != null)
     {
         this.DataSent(this, e);
     }
 }
Exemple #2
0
        // Send
        public void Send(byte[] byteStream, DestinationTuple destination)
        {
            PacketDataSentEventArgs e = new PacketDataSentEventArgs(byteStream, destination);

            try
            {
                this.ConnectionSocket.SendTo(byteStream, SocketFlags.None, (EndPoint)destination.RemoteEndPoint);
                this.OnDataSent(e);
            }
            catch (ObjectDisposedException exception)
            {
                throw exception;
            }
            catch (SocketException exception)
            {
                if (exception.SocketErrorCode == SocketError.WouldBlock)
                {
                    this.ConnectionSocket.BeginSendTo(byteStream, 0, byteStream.Length, SocketFlags.None, (EndPoint)destination.RemoteEndPoint, new AsyncCallback(this.SentCallback), e);
                }
                else
                {
                    throw exception;
                }
            }
        }
Exemple #3
0
 private void SentCallback(IAsyncResult result)
 {
     try
     {
         PacketDataSentEventArgs e = (PacketDataSentEventArgs)result.AsyncState;
         this.ConnectionSocket.EndSend(result);
         this.OnDataSent(e);
     }
     catch (Exception exception)
     {
     }
 }
 public void DataSent(object sender, PacketDataSentEventArgs e)
 {
     Log4netLogger.Info(MethodBase.GetCurrentMethod().DeclaringType, $"Send {e.Data.Count()} byte(s) 0x{ByteStreamUtil.ByteToHexBit(e.Data)} from {e.Destination.LocalEndPoint} to {e.Destination.RemoteEndPoint}");
 }
 public void DataSent(object sender, PacketDataSentEventArgs e)
 {
     Log4netLogger.Info(MethodBase.GetCurrentMethod().DeclaringType, $"Send {e.Data.Count()} byte(s) 0x{ByteStreamUtil.ByteToHexBit(e.Data)}");
 }