/// <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>
        /// 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) {}
        }
        /// <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>
		/// 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) {}
		}