When building websites, we often encounter different protocols. Both Socket and http protocols can realize data transmission, but what are the characteristics and shortcomings of the two transmission modes in website construction, and how to choose the appropriate transmission mode.
1 Data transmission mode
1.1 Definition and characteristics of socket transmission
The so-called socket is also called "socket", which realizes the physical connection between the website server and the client, and carries out data transmission. There are mainly two protocols, UDP and TCP. Socket is in the transport layer of network protocol.
UDP protocol: broadcast data transmission without data verification
TCP protocol: transmission control protocol, a connection oriented protocol that provides a reliable full duplex byte stream for user processes,
Characteristics of socket transmission:
advantage
1) The transmission data is byte level. The transmission data can be customized and the data volume is small (for mobile applications: low cost)
2) Short data transmission time and high performance
3) Suitable for real-time information interaction between client and server
4) It can be encrypted and has strong data security
Disadvantages:
1) The transmitted data needs to be analyzed and converted into application level data
2) High requirements on the development level of website construction developers
3) Compared with Http protocol transmission, it increases the amount of website development
1.2 Definition and characteristics of HTTP based transmission
At present, http protocol and Soap protocol (web service) based on http protocol are the main transmission protocols in website construction. The common ways are http post and get requests, web services, such as accessing a website http://www.hualai.net.cn , the http protocol is used.
Transmission characteristics of website construction based on http protocol
advantage:
1) Convenient interface based on website application level
2) The development level of website construction personnel is not high, and the fault tolerance is strong
Disadvantages:
1) The transmission speed is slow and the website data packet is large (the Http protocol contains auxiliary application information)
2) For example, real-time interaction, website server performance pressure.
3) Poor data transmission security
2 Applicable scope of each data transmission mode
2.1 Scope of Socket Transmission
Based on the characteristics of Socket transmission: Socket transmission mode is suitable for applications with high requirements on transmission speed, security, real-time interaction, cost, etc., such as online games, mobile applications, bank internal interaction, etc
2.2 Scope of application based on Http protocol transmission
Characteristics of http protocol based transmission: http protocol based transmission is suitable for website applications that require low transmission speed, low security requirements, and rapid development. Such as the company's OA website system, Internet services, etc.