Network programming - socket programming

1. Introduction to C/S Architecture

C/S architecture C: clint (client software)
            S: server (server software)

  Python programmers are application development programmers. The software they develop is application software. The application software must run on the operating system, and the operating system runs on the hardware. The application software cannot directly operate the hardware. The operation of the application software on the hardware must call The operating system interface, where the operating system operates the hardware.

The client software sends a message to the server software based on the network process:
  1. The client software generates data, stores it in the memory of the client software, and then calls the interface to send/copy the data in its own memory to the operating system memory
  2. The client After the operating system receives the data, it calls the network card to send the data according to the protocol specified by the client software.
  3. The network transmits the data
  . 4. The server software calls the system interface and wants to copy the data from the operating system memory to its own memory.
  5. Service After the terminal operating system receives the instruction of 4, it uses the same protocol as the client to receive data from the network card, and then copies it to the server software

  Suppose I want to write a program to send data to another computer, it must pass the tcp/ip protocol, but what is the specific implementation process? What should I do to encapsulate the data into tcp/ip packets, and what instructions should I execute to send the data to the peer machine?

  In short, what the socket does is to help you encapsulate various data of the tcp/ip protocol layer, data transmission, reception, etc. have been encapsulated for you by code, you only need to call a few lines of code , you can send messages to other machines .

2. Computer network

  Communication between computers must first have a physical link medium, such as network cables, switches, routers and other network devices.

  After the communication line is built, there is only a medium that can carry data at the physical level. In order to communicate, we need to organize our data according to certain rules , so that the other party can parse out the data according to the same rules after receiving the data. data.

3. TCP/IP

  According to different functions, people divide the Internet protocol into seven layers of osi or five layers of tcp/ip or four layers of tcp/ip.

  http://www.cnblogs.com/linhaifeng/articles/5937962.html#_label5

Five layers of TCP/IP :
  1. Application layer: specifies the data format of the application.
  2. Transport layer: Establish port-to-port communication
  3. Network layer: Introduce a new set of addresses to distinguish different broadcast domains/subnets. This set of addresses is the network address
  4. Data link layer: Defines electrical signals 5.
  Physical layer: mainly based on electrical characteristics to send high and low voltage (electrical signals), high voltage corresponds to digital 1, low voltage corresponds to digital 0

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325058535&siteId=291194637