Most chat systems do not do direct friend-to-friend connections, but instead route the messages through a central server farm.
That way, each participant only needs to know how to connect to the server, and the rather challenging part of P2P finding and matchmaking isn't needed.
Though another alternative is to use a central server to locate peers and initiate connection, and then let those peers connect to each other without the server's help. This is what Skype does, I believe - the server handles the contact list and provides your contact's IP on request, and when you want to message them or send a file, you connect to them directly (this is also why you can't send delayed messages - if you send a message when your contact is offline, it will be stored on your computer and sent when both of you are online again). Then, you get the best of both worlds - no need for complex matchmaking, and less security concerns about servers storing conversations (and other stuff). Well, actually, Skype apparently only does this for voice conversations (to avoid heavy bandwidth load on servers) but it could be done for text as well.