CN107733938A - The optimisation strategy of network speed of download is lifted on a kind of Android - Google Patents

The optimisation strategy of network speed of download is lifted on a kind of Android Download PDF

Info

Publication number
CN107733938A
CN107733938A CN201711297710.5A CN201711297710A CN107733938A CN 107733938 A CN107733938 A CN 107733938A CN 201711297710 A CN201711297710 A CN 201711297710A CN 107733938 A CN107733938 A CN 107733938A
Authority
CN
China
Prior art keywords
android
network
download
lifted
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201711297710.5A
Other languages
Chinese (zh)
Inventor
王旭东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kuwo Technology Co Ltd
Original Assignee
Beijing Kuwo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kuwo Technology Co Ltd filed Critical Beijing Kuwo Technology Co Ltd
Priority to CN201711297710.5A priority Critical patent/CN107733938A/en
Publication of CN107733938A publication Critical patent/CN107733938A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present invention relates to the optimisation strategy that network speed of download is lifted on a kind of Android, comprise the following steps:When receiving network download request, Socket objects are created first, between client and service end, the connection connect based on Socket objects is established, by connection connect, calls simultaneously request data write, obtain the data of service end return, client obtains the data read that service end returns, and closes Socket connections, completes Socket connections and obtains network downloading data process.The present invention, with by based on bottom Socket connections, supplemented by the HTTP request of upper strata, being optimized to network data request, effectively improving network speed of download.

Description

The optimisation strategy of network speed of download is lifted on a kind of Android
Technical field
The present invention relates to the processing technology field of network data request, lifted on specifically a kind of Android under network Carry the optimisation strategy of speed.
Background technology
Socket connections are an interfaces programmed for TCP and UDP, and TCP connections etc. can be established by it.
TCP and udp protocol belong to transport layer.
HTTP is the agreement of an application layer, and it is actually also established on Transmission Control Protocol.
We can only use when transmitting data(Transport layer)ICP/IP protocol, but at that rate, if should not With layer, just None- identified data content, if it is desired to make the data of transmission significant, then must use and arrive application layer protocol, answer Have much with layer protocol, such as HTTP, FTP, TELNET etc., oneself it can also define application layer protocol.WEB uses http protocol Make application layer protocol, to encapsulate HTTP text messages, then do transport layer protocol using TCP/IP and it is dealt on network.
TCP three-way handshake:Data are not transmitted in handshake procedure, server just starts to transmit number with client after shaking hands According to ideally, TCP connections are once establish, TCP connection meetings before either party in communication two party actively disconnects It is always maintained at down.
Socket connections, at least need a pair of sockets, are respectively:ClientSocket and serverSocket.Even Connect and be divided into 3 steps:
(1) server is monitored:The socket at server and delocalization specific client end, but the moment be in listening state;
(2) client request:The socket of client will describe the socket of its server to be connected, there is provided address and end Slogan, then propose connection request to server socket;
(3) connection confirms:After server socket receives the request that client socket is sent, customer in response end is socketed The request of word, and a new thread is established, client is issued in the description of the socket of server end.Once client confirms This description, just formal establish connect.And server socket keeps listening state, the socket of other clients is continued to The connection request of word.
HTTP is short connection:Client sends request and is required for server end back response.After request terminates, actively discharge Link, therefore be short connection.Common practice is, it is not necessary to any data, also to keep sending out to server at regular intervals Send the request of " keeping connection ".It can so ensure that client in server end is " reaching the standard grade " state.
HTTP connections use " request-response " mode, connection are not only established in request, and client is to service After the request of device end, server ability returned data.
Socket connects to be long:Socket connections are exactly TCP connections under normal circumstances, therefore Socket connections are once built Vertical, communication two party starts mutually to send out data content, until both sides disconnect.In actual applications, because network node is excessive, In transmitting procedure, it can be disconnected by node, therefore active state is in by poll express network, the node.
The basic network connection HttpURLConnection provided in Android is the short company based on http protocol Connect.
Advantage:
1st, the interface based on application layer is easy to use.
2nd, the development level required is not high, and fault-tolerance is strong.
Shortcoming:
1st, transmission speed is slow, and packet is big.
2nd, real-time, interactive is showed strictly according to the facts, server performance pressure is big.
3rd, data transmission security is poor.
So the problem of HttpURLConnection transmission speeds of the http protocol based on Android upper stratas are slow, is based on Socket has the advantages of transmission data time is short, and performance is high.
The content of the invention
For defect present in prior art, it is an object of the invention to provide lifted on a kind of Android under network Carry the optimisation strategy of speed, with by based on bottom Socket connections, supplemented by the HTTP request of upper strata, network data is asked into Row optimization, effectively improves network speed of download.
To achieve the above objectives, the present invention adopts the technical scheme that:
The optimisation strategy of network speed of download is lifted on a kind of Android, it is characterised in that comprise the following steps:
When receiving network download request, Socket objects are created first,
Between client and service end, the connection connect based on Socket objects is established,
By connection connect, simultaneously request data write is called, obtains the data of service end return,
Client obtains the data read that service end returns,
Socket connections are closed, Socket connections is completed and obtains network downloading data process.
On the basis of above-mentioned technical proposal, the completion Socket connections obtain network downloading data process, are compiled with C For so storehouses.
On the basis of above-mentioned technical proposal, so storehouses are encapsulated as TCP Client.
On the basis of above-mentioned technical proposal, so storehouses are called to be used for Android upper stratas by JNI.
On the basis of above-mentioned technical proposal, the encapsulation based on http is also provided on Android upper stratas, is passed through for upper strata HTTP request realizes network download request.
On the basis of above-mentioned technical proposal, the encapsulation based on http, specifically include:
Object is generated based on HttpURLConnection classes,
Related RequestProperty is set,
Object based on generation establishes connection connect,
Network inputs stream getInputStream, and read data are obtained,
The byte of reading is written to output stream OutputStream, and exported,
Network inputs stream getInputStream is closed, closes output stream OutputStream, and disconnect disconnect.
On the basis of above-mentioned technical proposal, HttpSession classes are generated based on HttpURLConnection classes, are used for Realize the network request on upper strata.
On the basis of above-mentioned technical proposal, in Android upper stratas, a management class DownloadCore is created, it is excellent First asked using the TCP Client of bottom, the HTTP request that upper strata is attempted if failure is handled.
The optimisation strategy of network speed of download is lifted on Android of the present invention, to be connected by bottom Socket Based on, supplemented by the HTTP request of upper strata, network data request is optimized, effectively improves network speed of download.
Brief description of the drawings
The present invention has drawings described below:
The flow chart of Fig. 1 present invention.
Embodiment
The present invention is described in further detail below in conjunction with accompanying drawing.
As shown in figure 1, the optimisation strategy of network speed of download is lifted on Android of the present invention, including following step Suddenly:
When receiving network download request, Socket objects are created first,
Between client and service end, the connection connect based on Socket objects is established,
By connection connect, simultaneously request data write is called, obtains the data of service end return,
Client obtains the data read that service end returns,
Socket connections are closed, Socket connections is completed and obtains network downloading data process.
On the basis of above-mentioned technical proposal, the completion Socket connections obtain network downloading data process, are compiled with C For so storehouses.It is compiled as Android dynamic link libraries (.so files).
On the basis of above-mentioned technical proposal, so storehouses are encapsulated as TCP Client.Bottom realizes encapsulation TCP client with C End, realizes basic network request, and data return.
On the basis of above-mentioned technical proposal, so storehouses are called to be used for Android upper stratas by JNI.
On the basis of above-mentioned technical proposal, the encapsulation based on http is also provided on Android upper stratas, is passed through for upper strata HTTP request realizes network download request.
On the basis of above-mentioned technical proposal, the encapsulation based on http, specifically include:
Object is generated based on HttpURLConnection classes,
Related RequestProperty is set,
Object based on generation establishes connection connect,
Network inputs stream getInputStream, and read data are obtained,
The byte of reading is written to output stream OutputStream, and exported,
Network inputs stream getInputStream is closed, closes output stream OutputStream, and disconnect disconnect.
On the basis of above-mentioned technical proposal, HttpSession classes are generated based on HttpURLConnection classes, are used for Realize the network request on upper strata.
On the basis of above-mentioned technical proposal, in Android upper stratas, a management class DownloadCore is created, it is excellent First asked using the TCP Client of bottom, the HTTP request that upper strata is attempted if failure is handled.
The content not being described in detail in this specification belongs to prior art known to professional and technical personnel in the field.

Claims (8)

1. the optimisation strategy of network speed of download is lifted on a kind of Android, it is characterised in that comprise the following steps:
When receiving network download request, Socket objects are created first,
Between client and service end, the connection connect based on Socket objects is established,
By connection connect, simultaneously request data write is called, obtains the data of service end return,
Client obtains the data read that service end returns,
Socket connections are closed, Socket connections is completed and obtains network downloading data process.
2. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 1, it is characterised in that:It is described complete Network downloading data process is obtained into Socket connections, so storehouses are compiled as with C.
3. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 2, it is characterised in that:So Storehouse is encapsulated as TCP Client.
4. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 2, it is characterised in that:Pass through JNI So storehouses are called to be used for Android upper stratas.
5. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 4, it is characterised in that: Android upper stratas also provide the encapsulation based on http, and network download request is realized by HTTP request for upper strata.
6. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 5, it is characterised in that:The base In http encapsulation, specifically include:
Object is generated based on HttpURLConnection classes,
Related RequestProperty is set,
Object based on generation establishes connection connect,
Network inputs stream getInputStream, and read data are obtained,
The byte of reading is written to output stream OutputStream, and exported,
Network inputs stream getInputStream is closed, closes output stream OutputStream, and disconnect disconnect.
7. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 6, it is characterised in that:It is based on HttpURLConnection classes generate HttpSession classes, for realizing the network request on upper strata.
8. the optimisation strategy of network speed of download is lifted on Android as claimed in claim 5, it is characterised in that: In Android upper stratas, a management class DownloadCore is created, the preferential TCP Client using bottom is asked, if failure The HTTP request for then attempting upper strata is handled.
CN201711297710.5A 2017-12-08 2017-12-08 The optimisation strategy of network speed of download is lifted on a kind of Android Pending CN107733938A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711297710.5A CN107733938A (en) 2017-12-08 2017-12-08 The optimisation strategy of network speed of download is lifted on a kind of Android

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711297710.5A CN107733938A (en) 2017-12-08 2017-12-08 The optimisation strategy of network speed of download is lifted on a kind of Android

Publications (1)

Publication Number Publication Date
CN107733938A true CN107733938A (en) 2018-02-23

Family

ID=61221076

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711297710.5A Pending CN107733938A (en) 2017-12-08 2017-12-08 The optimisation strategy of network speed of download is lifted on a kind of Android

Country Status (1)

Country Link
CN (1) CN107733938A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2625623A2 (en) * 2010-10-08 2013-08-14 Lumi Technologies Limited Multi-phased and partitioned content preparation and delivery
CN106507181A (en) * 2016-11-30 2017-03-15 北京酷我科技有限公司 A kind of method for being obtained and stored in line video data

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2625623A2 (en) * 2010-10-08 2013-08-14 Lumi Technologies Limited Multi-phased and partitioned content preparation and delivery
CN106507181A (en) * 2016-11-30 2017-03-15 北京酷我科技有限公司 A kind of method for being obtained and stored in line video data

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
ELLIOTTE RUSTY HAROLD: "《Java网络编程第4版》", 30 September 2014 *
陈荣超等: ""基于TCP socket和HTTP POST的现代有轨电车定位系统"", 《计算机应用与软件》 *
魏扬: ""基于JAVA Socket网络通信模型设计与实现"", 《内江科技》 *
黄洋: ""基于WAPI的移动安全支付解决方案的设计与实现"", 《中国优秀硕士学位论文全文数据库》 *

Similar Documents

Publication Publication Date Title
WO2019205907A1 (en) Intelligent device communication platform based on mqtt message protocol
CN103582174B (en) Wireless communication system for participating in display session offline
CN109327513B (en) Interaction method, interaction device and computer-readable storage medium
CN102790776B (en) Heartbeat connection normalizing processing method, terminal, server and communication system
WO2017045276A1 (en) Terminal interconnecting method, device, and storage medium
WO2010139151A1 (en) Method and system for realizing concurrent access of multi-kinds of bearer protocols on machine-to-machine (m2m) platform
CN101304436A (en) Load balancing method, system and equipment for implementing application layer conversation persistency
CN107360177B (en) A kind of message transmitting method and device based on UDP
CN104994079A (en) Access request processing method, access request processing device and acceleration server
CN105227418B (en) Data channel establishing method and communication equipment
CN102088460B (en) Method, device and system for transmitting streaming media data in restricted networks
CN104580158A (en) Distributed platform file and content distribution method and distributed platform file and content distribution system
CN110557354A (en) Method and device for realizing communication between nodes and electronic equipment
CN101567861B (en) Data synchronization method and application system between heterogeneous application systems
CN103379182A (en) Data transmission method and client sides
CN104821909A (en) Peer-to-peer data transmission method and system
CN109120540A (en) Method, proxy server and the computer readable storage medium of transmitting message
CN114615082A (en) System and method for simulating TCP duplex safety communication by using forward and reverse network gates
CN101159683A (en) Method and apparatus for controlling data flow
CN101888412B (en) Video push processing method and system serving live broadcast of mobile terminal
CN105897665B (en) Method for realizing TCP transmission in satellite network environment and corresponding gateway
CN110417875B (en) Method, system, equipment and storage medium for docking between cloud servers
CN104636210B (en) A kind of method and device for realizing Data Exchange
CN107733938A (en) The optimisation strategy of network speed of download is lifted on a kind of Android
CN105553986A (en) UDP-based multi-addressing limited real-time node communication method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180223