Пример #1
0
		/// <summary>
		/// Sends a YMSG packet.
		/// </summary>
		/// <param name="packet">The YMSG packet.</param>
		private IAsyncResult SendPacket(Packet packet)
		{
			var buf = new byte[BUFFER_SIZE];
			int len = packet.Write(buf, 0);
			return this.Stream.BeginWrite(buf, 0, len, new AsyncCallback(this.OnDataSent), null);
		}
Пример #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;
		}