I know this is a very broad spectrum question...
But how do programs such as MSN, AIM, YIM, Myspace, ICQ and all those actually connect to the internet?

I never opened a port for them in my router but i do believe that they use the TCP protocol.

Do they somehow configure my router through a uPNP or what ever it's called?

The router's firewall should stop it shouldn't it?

Also, what could i search for to find the code for this answer... or what is the code for this answer... this is a problem that i always have when making programs that communicate over the internet.

In my router's Port Forwarding table, i noticed that there's a free UDP Port open, the port number is 161 and it's set to the broadcast address for the network that i'm on (which means it will allow any IP address on the network to recieve traffic through this port).