Now that you understand how 2 computers talk to each other, let’s drill down further. In most circumstances, you will have multiple type of internet connections open at the same time. Perhaps you’re browsing the web while listening to streaming audio. Or you’re browsing internet while you check your email using Outlook or Thunderbird. All these types of connections, how do a packet or datagram knows which application it is intended to? Surely, you don’t want to have audio packets in the middle of your web page you’re browsing. Who knows how it would look like, or vice-versa.
Well, in addition to your IP address, you also have ports. Imagine your computer as a house. Then you can think of a port as a door or room in your house. Your house has an address (your external IP address). Each packets or datagrams will have a port designated for it. That way, each packets / datagrams won’t be mixed up.
There’s a post at Yahoo Answer that prompted me to write this article. I thought it’d be good to write a more in depth answer in hopes that my explanation clears enough for anyone to understand how computer network works. As always, I welcome comments / questions / critics that will help me and other readers understand better.