In the old sailing navy sodomites danced Pandy's hornpipe from the jewel block on the fore yard. William IV when he was at sea tried to stamp out the use of the 'detestable' word 'bugger'.
In my day Officers had to sign that they had read the annual CAFO on the subject. It included a direction, on encountering sodomites in action, e.g. during night rounds (it was on the list to look for along with fire risk and money left loafing), to separate them (meaning prevent further communication between them) but one imagined a rather nasty plooping noise. Merely being a homo was not a sacking offence (that came in later) only being caught at it. However I have no recollection of any cases in any of my ships; the Commander of the Tiger at one point was clearly as queer as a clockwork orange (in the contemporary phrase) but went on the become (appropriately perhaps) a rear admiral. He actually got married in Malta but when in our Moscow embassy was, shall we say, superseded by the presumably more active French naval attaché.
One of my contemporaries was invited by his Captain to have his resignation on his captain's desk by Colours next day and no more would be said, after a junior rate had complained of undue familiarity.
See also
https://www.timesofmalta.com/articl...r-court-martialled-for-homosexual-acts.386222