I suppose this question can be applied to some cultures in present time also, but for example, if a gay man in the middle ages in Europe (according to Wikipedia there was homophobic intolerance at this time: https://en.wikipedia.org/wiki/Homophobia#Origins) wanted to find another gay man, how would he do it without attracting unwanted and possibly dangerous attention from authorities/public/etc?
Firstly, I need to put my mod hat on. You are veering quite close to a "throughout history question." But since you do ask a specific question about the "middle ages" I will embrace my capacity to be flexible.
So this is a deeply complicated question. First and foremost, we need to start with the two major assumptions at the center of your question:
Once you remove those assumptions, it is near impossible to answer your question, as the underpinnings of the question effectively do not exist. I hope this did not seem harsh. LGBT history is a particularly difficult field, in part because all the terms and concepts we have at our disposal either did not exist or had a significantly different meaning at earlier parts of history, or in different communities. The word "Queer," for instance, has had roughly four separate and distinct meanings in the last century.
I hope this begins to, if not answer your question, at least recontextualize it.