Sociolinguistics is the term used to describe the connection between social behavior and language. Sociolinguistics can be very culture specific. In many cases sociolinguistics is very dependant on the gender, nationality, and dialect of those speaking. Many stereotype jokes actually derive from what are commonly accepted sociolinguistic tendencies of various regions, or nations. Basically, sociolinguistics describes what is socially acceptable or typical to be spoken.
As the name would imply sociolinguistics has a social factor. In fact, the language we use is dependant not only on regional or national location, or ethnic differences, but also how well we know each other. In many culture for instance, when speaking on the street one is very reserved and conservative both in terms of the number of words spoken as well as the use of enthusiastic or descriptive words, yet at home much casual. In almost all culture friends are treated differently in speech but many cultures formalize this into language as well. For instance in the Slavic languages there are different words used when addressing friends as opposed to unknown individual acquaintances and these can often be interpreted to determine how comfortable the speaker feels with you as well.
Another aspect of sociolinguistics is diglossia which in Greek means two languages. Diglossia describes when two distinct dialects are used within one community. For instance in Greece, old-Greek, which is much more formal is typically used in situations like university discussions and is distinct from the language you would hear, for instance, discussing the price or an item with a street vendor. This is similar to how some churches use different languages as well; Greek Churches use Koine Greek, Old Catholic Churches use Latin, Slavic Churches use Old Slavonic, etc.
Politeness theory is what governs what is acceptable or not acceptable to say to another person in certain situations. For instance the US Congress actually has a list of what is and is not acceptable for one member to say of another member, or another branch of government. In sociolinguistics it comes down to face value; specifically certain words which are bold enough to damage the reputation or self image of the speaker or hearer. An example would be the difference between saying "Mike is a really bad person" verses saying "Some people might have the idea that Mike isn’t a great person". This can have vast implications between cultures. For instance Japan is famous for never saying "no" even when they have no intention of doing something, and western diplomats have misinterpreted the intention to be polite as agreement.
In many cultures speech varies greatly between genders. For instance, many have noticed famous Russians like Maria Sharapova have last names ending in "A". This is because in the Russian language a feminine ending is added to the last name of women (This is true to such an extent that Russians can tell non Russians based on whether their name can be changed linguistically to add the feminine ending, or whether another regional ending is added!).
In western society it is typical for males to be forward and direct, and for women to use more polite, and reserved language. In many far eastern cultures it is impolite for men to speak directly at all and in fact difficult topics are often handled, although still very reserved, by women or wives. The language acceptable for use by men with women, and women with men is also different in many cultures. Also what words are used can differ between the genders as well. In Japanese a woman would use ‘ohiya’ to refer to water where as a man would use ‘mizu’.