Electromagnetic waves near perfect conductors. II. Casimir effect