Even if it might sound ego or superficial, I think friendship is being overrated. I went both ways already and I find the lonely side much more attractive.
Think about all the freedoms you have! Doing what you want when you want without having to worry about others. Of course, you can share your time with people you meet (at work, outside....), but you don't have to become friends to feel happy. I think that this way is also easier if you really DO want friends because nobody feels any pressure at the beginning. Socializing is an art form that some people just haven't mastered (I count myself in for this one), but practising might help.
In my opinion, my life hasn't been too bad the last ten years because I do what I like, and I rarely feel the need of having company. I found the switch to turn those feelings off, so maybe other people can learn how to do this, too? Having less obligations lowers your stress level a lot, so I guess the secret is to enjoy the alone time for as long as it lasts and embrace opportunities if they stare you in the face. Everyone has to find his or her own way of balance there.
I'm no mental doctor, but this is my opinion and also a little piece of personal advice for everyone out there struggling with loneliness.