官术网_书友最值得收藏!

The network

A single computer on its own can achieve a lot, but its capability becomes exponentially larger when it can communicate with other computers. This communication occurs among computers that belong to the same network.

A computer can be a part of a network through various means: such as an Ethernet cable or through Wi-Fi. In the previous chapter, we observed the output of the ifconfig command, which showed us the different interfaces through which our device could possibly be connected.

Now that we know a network can have multiple computers, the next question that arises is about how each computer is identified on the network. This is what each device's IP address (or IPv4 address, to be more precise) is used for. It specifies the location and acts as an identifier for each device connected to a network.

The dotted boundary in the figure represents a single network. For each individual network, every device must have a unique IP address. This IP address is only unique for a single network. If you notice, there are two devices that have the IP address of 192.168.0.4, which is fine since they are on different networks.

Each IP address is specific only to a single network, and each device can only have one IP address.

Our Raspberry Pi is nothing special. In the previous chapter, we found the Pi's IP address for the network that it was connected to.

Although each device has its own IP address, there will still be many services running on it. For example, we can have a web server and database running on our Pi at the same time, and both services must be communicated with independently. This is what ports are for.

Each port on a single device refers to one single service running on that device. As a principle, every program that needs to communicate with the outside world requires a port. Each device has port numbers ranging from 0 to 65535. Ports ranging from 0 till 1024 are reserved, and any port numbers after that can be used for our applications. Since we will be running most of our services on our Pi device itself, we will use a different port for each of them.

主站蜘蛛池模板: 永吉县| 崇义县| 兴安盟| 双辽市| 尖扎县| 乐平市| 白山市| 类乌齐县| 巴彦县| 九龙县| 汉沽区| 金溪县| 绍兴县| 丹阳市| 保定市| 科技| 花垣县| 冷水江市| 赤水市| 鄂州市| 蒲江县| 苍山县| 新闻| 高唐县| 莫力| 鱼台县| 克拉玛依市| 仁布县| 阿合奇县| 武陟县| 勐海县| 兰州市| 英吉沙县| 长武县| 永安市| 阜康市| 工布江达县| 留坝县| 章丘市| 冷水江市| 南康市|