Пример #1
0
        /// <summary>
        /// Handles the received data.
        /// </summary>
        private void OnDataReceived(IAsyncResult r)
        {
            var info = (ReadAsyncData)r.AsyncState;
            int len  = info.Stream.EndRead(r);

            this.ReadyToReceive();
//			if(len>650){
//				return;
//			}
            //
            // Reads the packet.
            var packet = new Packet();

            packet.Read(info.Buffer, 0, len);
            this.ProcessPacket(packet);
        }
Пример #2
0
        /// <summary>
        /// Sends and receives packet synchronously.
        /// </summary>
        /// <param name="packet">The request packet.</param>
        /// <returns>The response packet.</returns>
        private Packet SendAndReceivePacket(Packet packet)
        {
            //
            // Sends
            var buf = new byte[BUFFER_SIZE];
            int len = packet.Write(buf, 0);

            this.Stream.Write(buf, 0, len);

            //
            // Receives
            len = this.Stream.Read(buf, 0, BUFFER_SIZE);
            var resp = new Packet();

            resp.Read(buf, 0, len);
            return(resp);
        }
Пример #3
0
		/// <summary>
		/// Sends and receives packet synchronously.
		/// </summary>
		/// <param name="packet">The request packet.</param>
		/// <returns>The response packet.</returns>
		private Packet SendAndReceivePacket(Packet packet)
		{
			//
			// Sends
			var buf = new byte[BUFFER_SIZE];
			int len = packet.Write(buf, 0);
			
			this.Stream.Write(buf, 0, len);
			
			//
			// Receives
			len = this.Stream.Read(buf, 0, BUFFER_SIZE);
			var resp = new Packet();
			resp.Read(buf, 0, len);
			return resp;
		}
Пример #4
0
		/// <summary>
		/// Handles the received data.
		/// </summary>
		private void OnDataReceived(IAsyncResult r)
		{
			var info = (ReadAsyncData)r.AsyncState;
			int len = info.Stream.EndRead(r);
			this.ReadyToReceive();
//			if(len>650){
//				return;
//			}
			//
			// Reads the packet.
			var packet = new Packet();
			packet.Read(info.Buffer, 0, len);
			this.ProcessPacket(packet);
		}