Пример #1
0
        /// <summary>
        /// to receive bytes from connection.
        /// </summary>
        /// <param name="timeout">
        /// a TimeSpan object that specifies the timeout for this operation.
        /// </param>
        /// <param name="maxCount">
        /// an int value that specifies the maximum count of expect bytes.
        /// </param>
        /// <returns>
        /// a bytes array that contains the received bytes.
        /// </returns>
        /// <exception cref="ObjectDisposedException">
        /// thrown when this object is disposed.
        /// </exception>
        public byte[] ExpectBytes(TimeSpan timeout, int maxCount)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("NetbiosServerConnection");
            }

            return(ExpectBytesVisitor.Visit(this.buffer, timeout, maxCount));
        }
        /// <summary>
        /// to receive bytes from connection.<para/>
        /// the underlayer transport must be TcpClient, Stream or NetbiosClient.
        /// </summary>
        /// <param name="timeout">
        /// a TimeSpan object that specifies the timeout for this operation.
        /// </param>
        /// <param name="maxCount">
        /// an int value that specifies the maximum count of expect bytes.
        /// </param>
        /// <returns>
        /// a bytes array that contains the received bytes.
        /// </returns>
        /// <exception cref="ObjectDisposedException">
        /// thrown when this object is disposed.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// thrown when stream client is not connected, must invoke Connect() first.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// thrown when the connection is closed, there is no data anymore.
        /// </exception>
        public byte[] ExpectBytes(TimeSpan timeout, int maxCount)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("StreamTransport");
            }

            if (this.stream == null)
            {
                throw new InvalidOperationException(
                          "stream client is not connected, must invoke Connect() first.");
            }

            return(ExpectBytesVisitor.Visit(this.buffer, timeout, maxCount));
        }
Пример #3
0
        public byte[] ExpectBytes(TimeSpan timeout, int maxCount)
        {
            ValidateConnectionDisposed();

            return(ExpectBytesVisitor.Visit(this.buffer, timeout, maxCount));
        }