Пример #1
0
        public bool ListeningReader(byte[] data, int length, TcpTransportConnection connection)
        {
            Logger.Info("Received packet [size=" + length + "]");

            long totalInBytes = Convert.ToInt64(inBytes.Text) + length;

            Invoke(
                new Action(() => { inKbps.Text = (totalInBytes / (Environment.TickCount - startTime) * 1000 / 1024).ToString(); }

                           ));
            Invoke(new Action(() => { inBytes.Text = totalInBytes.ToString(); }));
            byte[] newBuffer = new byte[recvBuffer.Length + length];
            Array.Copy(recvBuffer, newBuffer, recvBuffer.Length);
            Array.Copy(data, 0, newBuffer, recvBuffer.Length, length);
            recvBuffer = newBuffer;
            int markerCount  = recvBuffer.Length / marker;
            int markerLength = markerCount * marker;

            Invoke(
                new Action(
                    () =>
            {
                md5total.Text = markerCount.ToString() + "M"; md5sum.Text = Util.getSingleton().getMD5Hash(recvBuffer, 0, markerLength);
            }));
            return(true);
        }
        private bool ReadReply(byte[] bytes, int length, TcpTransportConnection connection)
        {
            var reply = Encoding.UTF8.GetString(bytes, 0, length);

            if (reply.Equals(_echoStore))
            {
                Logger.Info("Received " + reply);
                _waiter.Set();
            }
            else
            {
                Logger.Warn("Received unexpected " + reply);
            }
            return(true);
        }
Пример #3
0
        public bool ListeningReader(byte[] data, int length, TcpTransportConnection connection)
        {
            Logger.Info("Received packet [size=" + length + "]");

            long totalInBytes = Convert.ToInt64(inBytes.Text) + length;
            Invoke(
                new Action(() => { inKbps.Text = (totalInBytes / (Environment.TickCount - startTime) * 1000 / 1024).ToString(); }

                    ));
            Invoke(new Action(() => { inBytes.Text = totalInBytes.ToString(); }));
            byte[] newBuffer = new byte[recvBuffer.Length + length];
            Array.Copy(recvBuffer, newBuffer, recvBuffer.Length);
            Array.Copy(data, 0, newBuffer, recvBuffer.Length, length);
            recvBuffer = newBuffer;
            int markerCount = recvBuffer.Length / marker;
            int markerLength = markerCount * marker;
            Invoke(
                new Action(
                    () =>
                    {
                        md5total.Text = markerCount.ToString() + "M"; md5sum.Text = Util.getSingleton().getMD5Hash(recvBuffer, 0, markerLength);
                    }));
            return true;
        }
 private bool Reader(byte[] data, int length, TcpTransportConnection connection)
 {
     Logger.Debug("Got some data to echo " + Encoding.UTF8.GetString(data, 0, length));
     return(connection.SendDataToTransportSocket(data, length));
 }