Exemplo n.º 1
0
 private void OnDataSent(PacketDataSentEventArgs e)
 {
     if (this.DataSent != null)
     {
         this.DataSent(this, e);
     }
 }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 3
0
 private void SentCallback(IAsyncResult result)
 {
     try
     {
         PacketDataSentEventArgs e = (PacketDataSentEventArgs)result.AsyncState;
         this.ConnectionSocket.EndSend(result);
         this.OnDataSent(e);
     }
     catch (Exception exception)
     {
     }
 }
Exemplo n.º 4
0
 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}");
 }
Exemplo n.º 5
0
 public void DataSent(object sender, PacketDataSentEventArgs e)
 {
     Log4netLogger.Info(MethodBase.GetCurrentMethod().DeclaringType, $"Send {e.Data.Count()} byte(s) 0x{ByteStreamUtil.ByteToHexBit(e.Data)}");
 }