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

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.

主站蜘蛛池模板: 黔西| 锡林郭勒盟| 乐至县| 宜兴市| 阿拉善盟| 铁力市| 普安县| 新邵县| 化德县| 偃师市| 肃宁县| 鹤壁市| 达尔| 兴国县| 什邡市| 正定县| 南宫市| 磐安县| 宜城市| 同江市| 德化县| 舞钢市| 衡阳县| 湘乡市| 彰化县| 云霄县| 开阳县| 江阴市| 太康县| 鱼台县| 东安县| 无棣县| 永安市| 根河市| 香河县| 乌审旗| 措勤县| 尼玛县| 巴塘县| 五家渠市| 乳源|