Rude, I recognized a lot of myself in your post; a lot of those thoughts and experiences could have been written by me at one time or another. I'm pretty strongly introverted (and I'm guessing you are too). Big crowds and lots of noise wear me out mentally. Also I'm not a fan of formalwear and I really,
really don't like to dance; this makes weddings (to name one thing) a rather excruciating experience, even with friends. I do enjoy drinking, but booze only gets you so far.
The thing to remember is that
you have absolutely every right at social gatherings to be as happy and comfortable as you want. Taking a minute to break away from the group, go for a stroll by yourself, and recharge your mental and emotional batteries is perfectly normal and a VERY common strategy for introverts. Heading to a quiet corner of the room works too. You needn't feel self-conscious about doing this: it is a party, the goal is enjoyment, and you are enjoying yourself in the way most comfortable to your style. Also the thing about big gatherings is that unless you are wearing a lampshade and dancing atop a table, people are not generally paying attention to you. It's understandable to go to a party with 80 people and expect there to be 80 sets of eyes watching your every move, but that's not really what's happening. Finally, one very important note: on the extremely rare chance where there is someone who sees you doing your own thing, and is for some reason inclined to think less of you for it,
fuck 'em. They are wrong.
As for online friends: yes, absolutely, they count. There are people whom I have met and become close friends with online, in some cases going a few years before meeting them IRL. When eventually I did meet them in person, it merely confirmed the friendship that already existed. I have always found that to be the case with my online acquaintances. That said, there really is a certain psychic benefit that you reap from flesh-and-blood, personal, face-to-face human interaction, which you really can't get any other way. That's just how us humans are built. Being among other people -- not even being the center of attention, just being among people -- is good for you, like vitamins for the soul. Don't neglect it.
Finally, nth-ing what others have said about counseling. Talking to a counselor can yield marvelous benefits, and you don't even need to wait until your life is an unbearable mess to do it.