165: Sockets And Ports: The Hidden Pieces.

Take Up Code - A podcast by Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categories:

How does one application communicate with another application? So far, in the last several episodes, I’ve explained how to identify and find computers on a network, how to establish connections, how to think about communication in terms of seven layers, and a few different protocols. There are many more protocols. And there are many different types of networks not based on the internet protocol. Many of the concepts still apply and once you understand all of these things, you should be able to understand completely different ways to transport information between computers. But there’s one final piece that I haven’t described yet. I’ve never actually seen or heard of a computer itself that wants to talk to another computer. It’s always software running on a computer that does the communicating. And computers can run many different programs at once. Each running program is called a process. So what we really need to understand is how one process can communicate with another process. That’s the topic of today’s episode. Specifically, this episode describes how to communicate using sockets over an IP network. Since computers can run multiple processes, just routing communication packets to the right computer isn’t enough. We need some way to specify what process should receive the information. And that’s where ports come in. Think of it like this, when you send a letter to someone, you don’t just put the address, you also put a name on the envelope. The post office doesn’t really need the name to deliver the letter. Sure, they might check it just to make sure. But really, all the post office needs is the address. This is like the IP address is all that’s needed to deliver a packet to the right computer. But once it reaches the destination, the port acts like the name. The port lets the computer know which process is interested to receive the data. Sockets are resources provided by the operating system or drivers installed as part of the operating system. You may have a library called sockets or a library that uses something called sockets. This is a common name for network programming over an IP network. A socket is a concept that represents a communication channel with another computer. Make sure to listen to the full episode to learn how to use sockets and ports when writing networking software. And if you subscribe to this podcast in iTunes or other podcast directory, then you’ll get future episodes delivered automatically. You can also read the full transcript below. Transcript So far, in the last several episodes, I’ve explained how to identify and find computers on a network, how to establish connections, how to think about communication in terms of seven layers, and a few different protocols. There are many more protocols than I described here. And there are many different types of networks not based on the internet protocol. Many of the concepts still apply and once you understand all of these things, you should be able to understand completely different ways to transport information between computers. But there’s one final piece that I haven’t described yet. While it’s great that you know all of this, I’ve never actually seen or heard of a computer itself that wants to talk to another computer. It’s always software running on a computer that does the communicating. And computers can run many different programs at once. Each running program is called a process or sometimes an application. I tend to think of an application as the software itself. Like what you buy from the store. And a process is the running instance of an application. Sometimes, I might mix these terms up. But in general, a process is not something you buy. A process is software that’s running on your computer. So what we really need to understand is how one process can communicate with another process. That’s the topic of today