[Switch] The interaction method between the server and the client (Socket, http protocol) and their respective characteristics and scope of application

foreword

A few days ago, I designed a data interaction application between an Android phone and a server, and I had doubts about the realization of data transmission. Both Socket and http protocols can realize data transmission, but what are the characteristics and shortcomings of the two transmission methods, and how to choose the appropriate transmission method.

 

Data transmission method

1.1 Definition and characteristics of Socket transmission

       The so-called socket is usually also called " socket ", which realizes the physical connection between the server and the client, and performs data transmission. There are mainly two protocols : UDP and TCP . Socket is in the transport layer of the 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 to user processes,

 

Features of Socket  transmission:

   advantage

            1)   The transmission data is byte-level, the transmission data can be customized, and the amount of data is small (for mobile phone applications: low cost)

2)  Short data transmission time and high performance

3)  Suitable for real-time interaction of information between client and server

4)  Can be encrypted , strong data security

 

   shortcoming:

1)  The transmitted data needs to be parsed and converted into application-level data

2)  High requirements for the development level of developers

3)  Compared with Http protocol transmission, the development volume has been increased

 

1.2   Definition and Characteristics of Transmission Based on Http Protocol

       At present , there are mainly http protocol  and Soap protocol ( web service ) based on http protocol. The  common  methods are http post  and get requestsand web  services.

 

Transmission characteristics based on http protocol

   advantage:

1)  Easy to use based on application-level interface

2)  The programmer's development level is not high, and the fault tolerance is strong

 

   shortcoming:

1)  The transmission speed is slow and the data packet is large (the Http protocol contains auxiliary application information)

2)  Such as real-time interaction, the server performance pressure is high.

3)  Poor data transmission security

 

Scope of application of each data transmission method

 2.1 Scope of Socket transmission

     Features based on Socket transmission : Socket  transmission is suitable for applications with high requirements for transmission speed, security, real-time interaction, and costs, such as online games, mobile applications, and internal bank interactions.

 

 2.2  Scope of application based on Http protocol transmission

          Characteristics of transmission based on http protocol : The transmission method based on http protocol is suitable for transmission speed, security

       Applications that are not very demanding and require rapid development. Such as company OA system, Internet service, etc.

 

This article is reproduced from: Xu Wenbing's IT blog  link: http://www.cnblogs.com/macroxu-1982/archive/2011/01/12/1933722.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326824358&siteId=291194637