Generally, there are four privileged communications - doctor-patient, priest-parishioner, husband-wife and attorney-client. The basic idea is that a defendants ability to tell the truth to these people outweighs the governments right to know the content of the communication. There are a number ways this privilege is waived, either on purpose or by accident. As an example, an accidental waiver would be having the communication in a way that is could be overhead and obviously wasn’t private - say you discuss the particulars of your case with your attorney but in front several other people.