When viewed from a dog's perspective, it's easy to see why human/dog mishaps happen. An affable pup will often tolerate his own human family's misguidedly rude, strange-ish behavior, but coming from someone who is new to him, the reaction can be very different. At the end of the above scenario, the dog might bite, feeling a need to protect himself and his human. What will follow is a scolding from the very human this dog was trying to protect. Sometimes a dog will get a bad reputation and may even be put down for being vicious because, to unaware humans, a bite like this comes seemingly unprovoked and "out of nowhere." It's a sad, sad tale!
This is how I advise many of my clients to behave when meeting a new friend's dog: When you arrive, greet your human friend, but pretty much ignore the dog. To dogs, this is not rude, it is actually respectful and polite. If your friend introduces you to the dog, use calm energy (with a timid dog, high energy can cause what we trainers call "excitable pee"... and excitable pee is... exactly what it sounds like...) If possible, don't stand directly facing the dog (as dogs may see this as a challenging posture.) It's best to stand alongside the dog (a polite dog posture), and turn your head to look at him very briefly, say "hi", then look away. Do not make extended eye contact (as dogs may see this as a dominant, possibly-aggressive stare-down type of gesture.) Let him come up to you (if he wants to.) Have your hands dropped down alongside your body and allow him to get a good sniff (your scent is like ID to a dog.) By this point, most dogs will have likely established that you are not a threat. He might go off somewhere on his own. A confident, friendly, polite dog might even come up and sit right alongside you, intrigued by your respectful, calm, polite alpha dog behavior! If you feel the dog is comfortable, this is when you may ask your host if it's OK to pet him. If it's OK, let him sniff your hand, then pet him under the chin (patting on the top of the head is, between dogs, an uncomfortable, somewhat rude gesture... and to some dogs this can even cause an aggressive reaction.) If your friend is in the process of training her dog to welcome visitors, she might invite you to give (or toss) her dog a treat. After you've had a positive introduction, focus your attention on your human friend and whatever activity it is that you got together to do!
And so, an age-old mystery is solved for all of you who've wondered why a dog winds up following around the one guest at a party who tries to ignore that dog! The dog will, without fail, seem drawn to the poor man and sit right next to him all night. Most likely, that dog is thinking: "Finally! A human with some manners! This guy is cool...obviously the leader of the pack!"