As soon as the friend of your friend, which, henceforth, will be referred to as "the acquaintance," comes to greet your friend, offer a similar greeting to him (the acquaintance, not your friend - you've already greeted your friend, I hope). You don't have to wait for eye contact from the acquaintance or for him (the acquaintance) to acknowledge your presence, before offering a greeting. A smile and a handshake is not necessary and is in fact not preferable, because rapport must be developed, before further social protocols are established. Though this may vary based on the culture and customs surrounding friendships between the males of your demographic group.
Minimal conversational engagement is acceptable. However, do not, under any circumstance, proceed to make jokes at the acquaintance's expense, especially jokes about the vaginal elasticity of acquaintance's mother or her sexual proclivities, even if the acquaintance has referred to your friend's mother as a, "loose cumslut."
When idly standing or sitting by and listening during conversation between your friend and the acquaintance respectfully stay silent and only interject, if you believe the content of your interruption to be of utmost import and relevance. You may look at the acquaintance when they are speaking. However, do not maintain eye contact for greater than three seconds (or 3000 milliseconds, if you prefer), else this may be perceived as a physical challenge of dominance and martial combat, or worse, a perceived inclination towards homosexual interest. If ever any sentence uttered by yourself directed towards the acquaintance could be misinterpreted or misconstrued as having homosexual connotations, you absolutely must, without exception, add the phrase, "no homo." This is non-negotiable.
When the conversation between your friend and the acquaintance ends and they part ways a formal or informal farewell is not strictly necessary, and you may now resume your social activity with your friend prior to the entrance of the acquaintance into your social space.