Ejemplo n.º 1
0
        /// <summary>
        /// Returns the stream used to read and write data to the remote host
        /// </summary>
        public TransportStream GetStream()
        {
            // check object state
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            if (_stream == null)
            {
                _stream = new TransportStream(_transport, true);
            }

            return(_stream);
        }
Ejemplo n.º 2
0
        static byte[] ReceiveBuffer(TransportStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            // receive buffer size
            int size = reader.ReadInt32();

            if (size > 0)
            {
                // receive buffer data
                byte[] buffer = new byte[size];
                reader.Read(buffer, 0, size);
                return buffer;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 3
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (_stream == null)
            {
                try
                {
                    // if stream is not created we must close transport manually
                    _transport.Close();
                }
                catch
                {
                    // it seems reasonable to ignore this error
                }
            }

            _transport = null;
            _stream    = null;
            _disposed  = true;
        }
Ejemplo n.º 4
0
        static void SendBuffer(TransportStream stream, byte[] buffer)
        {
            BinaryWriter writer = new BinaryWriter(stream);

            if ((buffer != null) && (buffer.Length > 0))
            {
                // send buffer size
                writer.Write((Int32)buffer.Length);

                // send buffer data
                writer.Write(buffer);
            }
            else
            {
                // send NULL size
                writer.Write((Int32)0);
            }
        }
Ejemplo n.º 5
0
		protected virtual void Dispose(bool disposing)
		{
			if (_disposed)
				return;

			if (_stream == null)
			{
				try
				{
					// if stream is not created we must close transport manually
					_transport.Close();
				}
				catch
				{
					// it seems reasonable to ignore this error
				}
			}

			_transport = null;
			_stream = null;
			_disposed = true;
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Returns the stream used to read and write data to the remote host
		/// </summary>
		public TransportStream GetStream()
		{
			// check object state
			if (_disposed)
				throw new ObjectDisposedException(GetType().FullName);

			if (_stream == null)
			{
				_stream = new TransportStream(_transport, true);
			}

			return _stream;
		}