/// <summary>
		/// Parse the bytes given, and return the number of commands parsed.
		/// </summary>
		/// <param name="bytes">The bytes representing the commands</param>
		/// <returns>The number of commands parsed</returns>
		private static int parseBytes(byte[] bytes) {
			int commands = 0;
			ConnectionState parser = new ConnectionState();
			parser.setObjectReceivedAction(args => commands++);
			parser.buffer = bytes;
			try {
				parser.update(bytes.Length);
			} catch {
				return 1;
			}
			return commands;
		}
		/// <summary>
		/// Advance the buffer in the state object.
		/// </summary>
		/// <param name="state">The state object</param>
		/// <param name="bytesRead">The number of bytes read from the socket.</param>
		private static void updateState(ConnectionState state, int bytesRead) {
			state.update(bytesRead);
		}
		/// <summary>
		/// Handler for receiving data.
		/// </summary>
		/// <param name="client">The socket to receive on.</param>
		private void recvData(Socket client) {
			if (!_connectDone.Wait(_connectTimeout))
				onConnectionError();
			ConnectionState state = new ConnectionState(_encoding);
			state.setObjectReceivedAction(onObjectReceived);
			state.workSocket = client;
			try {
				client.BeginReceive(state.buffer, 0, ConnectionState.BUFFER_SIZE, 0, new AsyncCallback(recvData_then), state);
			} catch (ObjectDisposedException) {}
		}