Beispiel #1
0
        /// <summary>
        /// 从socket中接收数据输出到接收器中
        /// </summary>
        public static void Read(Socket socket, AbstractOutputReceiver receiver, int bufSize)
        {
            socket.ReceiveBufferSize = bufSize;
            var data  = new byte[bufSize];
            int count = -1;

            try
            {
                while (count != 0)
                {
                    count = socket.Receive(data);
                    if (count <= 0)
                    {
                        break;
                    }
                    receiver.Add(data, 0, count);
                }
            }
            catch (SocketException sex)
            {
                throw new ApplicationException(String.Format("No Data to read: {0}", sex.Message));
            }
            finally
            {
                receiver.Flush();
            }
        }
Beispiel #2
0
        /// <summary>
        /// 从socket中接收数据输出到接收器中
        /// </summary>
        public void Read(AbstractOutputReceiver receiver, int bufSize)
        {
            CurAdbSocket.ReceiveBufferSize = bufSize;
            var data  = new byte[bufSize];
            int count = -1;

            try
            {
                while (count != 0)
                {
                    count = CurAdbSocket.Receive(data);
                    if (count <= 0)
                    {
                        break;
                    }
                    receiver.Add(data, 0, count);
                }
            }
            finally
            {
                receiver.Flush();
            }
        }