Dogs in heat
In this case it's tougher on the male dog, because their sexual needs are not limited to a determined time, they're all year long. Generally man is the one to chose what kind of breeds to mix, because a dog will not decide this on it's own.
Substitute against sexual frustration
It may occur, in rare occasions, that a dog will consider a person as a mate and therefore try to mate you. Or another case is if it's a male, will try to mount this one as well.
The act of mounting is just a substitute and has nothing to do with sodomy or homosexuality. It is simply trying to satisfy it's needs or make a demonstration of self-control.
The act of wrapping itself around your legs can be quite bothersome. It straps it's front legs around yours and starts to make energetic movements. When this occurs, distract the dog by bringing out aso he can play with. In this case scolding is not necessary and can be contradictory, one strong reprimand will do.
Male and female
When a male dog smells the odor of a female dog in heat, it gets excited. One way to tell if the male dog has sensed it; if it's concentrated on the scent and lifts it's head up once in a while and goes back to smelling it, it's teeth chatter and it's it will set it's sight on a vague distance; their chemical reaction is very strong. You should hold the very tightly and not let go, for even the dog that has had an excellent education will struggle to be able to get closer to the "unknown female dog".
In Spring time when most of the femaleare in heat, whether they be far or near, the male get especially excited. They are restless and anxious to get near to one of them; they will dig beneath the fence, jump or climb over them, run out of the front door, run away during walks, things that you would never even think about, as well as, sorrowfully whining.
seeFIDOWays of conduct or behaviorDogs' Two LanguagesThe Dog's TailThe Man-Dog LanguageThe way dogs express themselvesDogs in heatSome advice for you; dog ownersA female dog becomes a motherEncounters and fights between dogsAvoiding a dog fight