Before learning about networks, review the basics of computer networks.
Lu Xun said that there is a huge copy of the article in the world. If you have any questions, you can copy the book based on your basic knowledge.
A layered model
1. Why Layer
In order to simplify the network design complexity, communication protocols adopt a layered structure, and Protocols at different layers are mutually independent and efficient in coordination.
The structure of complex communication protocols should be hierarchical. Layered protocols can bring a lot of convenience:
The advantages of layering are:
A> good flexibility: When any layer changes, as long as the interface relationship remains unchanged between the layers, the layers above or below will not be affected.
In addition, the services provided by a layer can be modified. When the services provided by a layer are no longer needed, you can even cancel the layer for easier management.
B> each layer is independent: interfaces are standardized between layers, allowing different products to provide only one part of the functions of each layer. A layer does not need to know how its next layer is implemented,
You only need to know the services provided by the layer through the interface between layers. Since each layer only implements a relatively independent function, it is easier to implement it!
2 layers
Standard layer-7 structure and practical layer-5 Structure
The socket corresponds to the transport layer and network layer.
Introduction to socket 2
Socket is the socket. The most primitive socket is inherited from Unix systems. Later Microsoft launchedWinsocket.
Socket programming involves some concepts such as address, port, and byte order. It is best to understand.
Here we will talk about the socket connection process,
There are roughly three major steps:
1. server listening
2 client request connection
3 Connection Confirmation
The next section describes the specific connection steps in detail.