CN103166994A - Method and device of obtaining network data - Google Patents

Method and device of obtaining network data Download PDF

Info

Publication number
CN103166994A
CN103166994A CN2011104181074A CN201110418107A CN103166994A CN 103166994 A CN103166994 A CN 103166994A CN 2011104181074 A CN2011104181074 A CN 2011104181074A CN 201110418107 A CN201110418107 A CN 201110418107A CN 103166994 A CN103166994 A CN 103166994A
Authority
CN
China
Prior art keywords
socket
network data
pond
free time
idle
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
CN2011104181074A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN2011104181074A priority Critical patent/CN103166994A/en
Publication of CN103166994A publication Critical patent/CN103166994A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a method and a device of obtaining network data and belongs to the field of network communication. The method includes the following steps: when obtaining of the network data is needed, judging whether a vacant socket exists; if the result is yes, using the vacant socket to obtain the network data. The method and the device of obtaining the network data save the time-consuming process of 'establishing a Socket and connecting a gateway' in the prior art due to repeat use of the established socket, prevent a browser from conducting the procedure of 'establishing the Socket and connecting the gateway' every time the network data is obtained, and obtain the network data faster. The method and the device of obtaining the network data can be used in a mobile terminal such as a cell phone, a tablet and the like.

Description

Obtain method and the device of network data
Technical field
The present invention relates to network communication field, particularly a kind of method and device that obtains network data.
Background technology
By surfing the Net such as the mobile terminal of mobile phone, panel computer, MID (Mobile Internet Devices, mobile internet device) and so on, it is a kind of network access that in modern society, people commonly use.
When the user adopts these mobile terminal network visitings, usually utilize the browser access that runs on these mobile terminals to adopt the wireless network of WAP (Wireless Application Protocol, WAP (wireless application protocol)) agreement.In prior art, when these browsers adopted the wireless network of wap protocol in access, the step of obtaining network data was mainly: the first, create Socket (Socket, socket) and linking objective gateway; The second, send connection request; The 3rd, receiving network data; The 4th, complete and close Socket.
In realizing process of the present invention, the inventor finds that there is following problem at least in prior art: these browsers are opened a web page interlinkage when obtaining network data, just comprise in maximum several steps consuming time " create Socket, and the linking objective gateway " this step.On the mobile terminal than low side, the time that all needed do not wait in 1.5 seconds to 5 seconds as " create Socket and linking objective gateway " this step 1, such time-delay has brought bad experience to the user.Simultaneously, when these browsers obtain network data, all need to carry out once the process of " creating Socket and linking objective gateway " at every turn, wasted the more time.
Summary of the invention
In order to make browser reduce as far as possible " creating Socket and linking objective gateway " this repetitive process, the embodiment of the present invention provides a kind of method and device that obtains network data.Described technical scheme is as follows:
According to an aspect of the present invention, the embodiment of the present invention provides a kind of method of obtaining network data, and described method comprises: when needs obtain network data, judge whether to exist idle socket; If have idle socket, adopt the socket of described free time to obtain network data.
Further, described judge whether to exist idle socket after, also comprise: if there is no idle socket creates new socket; Adopt described new socket to send connection request, to obtain network data.
Further, described judge whether to exist idle socket before, also comprise: be pre-created the socket pond that is connected and fixed the socket of gateway for storage; Describedly judge whether to exist idle socket specifically to comprise: judge the socket that whether has the free time in described socket pond.
Further, the socket of described described free time of employing obtains network data and specifically comprises: the socket of described free time is labeled as uses; Adopt the described socket that is using that is marked as to send connection request, to obtain network data.
Further, adopt after socket obtains network data, also comprise: judge that described socket is socket in described socket pond or the socket of new establishment; If the socket in described socket pond is labeled as the free time with described socket; If the new socket that creates, the socket with described new establishment is labeled as the free time, and puts into described socket pond.
Further, described method also comprises: whether the free time that judges the socket of the free time in described socket pond surpasses reservation threshold; If so, close the socket of described free time and it is removed from described socket pond.
According to a further aspect in the invention, the embodiment of the present invention also provides a kind of device that obtains network data, and described device comprises: the socket administration module, be used for when needs obtain network data, and judge whether to exist idle socket; Socket uses module, is used for adopting the socket of described free time to obtain network data when there is idle socket in described socket administration module judgement.
Further, the described device that obtains network data also comprises the socket creation module;
Described socket creation module is used for creating new socket when there is not idle socket in described socket administration module judgement;
Described socket uses module, also is used for adopting described new socket to send connection request, to obtain network data.
Further, the described device that obtains network data also comprises:
The socket pond is used for the socket that storage is connected and fixed gateway;
Described socket administration module is used for judging whether described socket pond exists idle socket.
Further, described socket administration module specifically comprises: the socket indexing unit;
Described socket indexing unit is labeled as for the socket with the described free time and uses;
Described socket uses module, is used for adopting the described socket that is using that is marked as to send connection request, to obtain network data.
Further, described socket administration module also comprises: the socket judging unit;
Described socket judging unit is used for described socket and uses module to adopt after socket obtains network data, judge that described socket is socket in described socket pond or the socket of the new establishment of described socket creation module;
Described socket indexing unit also is used for when the described socket of described socket judgment unit judges is the socket in described socket pond, it being labeled as the free time;
Described socket indexing unit also is used for when the described socket of described socket judgment unit judges is the new socket that creates of described socket creation module, and the socket with described new establishment is labeled as the free time, and puts into described socket pond.
Further, described socket administration module also comprises: overtime judging unit and socket remove the unit;
Described overtime judging unit is used for judging whether free time of socket of the free time in described socket pond surpasses reservation threshold;
Described socket removes the unit, and the free time of socket that is used for the free time in the described socket of described overtime judgment unit judges pond is when surpassing reservation threshold, closes described socket and it is removed from described socket pond.
The beneficial effect that the technical scheme that the embodiment of the present invention provides is brought is:
By carrying out multiplexing to the socket that has created, saved the process of more " create Socket and also connect gateway " consuming time in the prior art, all carry out once the step of " create Socket and connect gateway " at every turn when making browser not need to obtain network data, thereby can realize at faster speed obtaining of network data.
Description of drawings
In order to be illustrated more clearly in the technical scheme in the embodiment of the present invention, during the below will describe embodiment, the accompanying drawing of required use is done to introduce simply, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the method flow diagram of the method for obtaining network data that provides of the embodiment of the present invention one;
Fig. 2 is the method flow diagram of the method for obtaining network data that provides of the embodiment of the present invention two;
Fig. 3 is the block diagram of the device that obtains network data that provides of the embodiment of the present invention three;
Fig. 4 is the block diagram of the socket administration module that provides of the embodiment of the present invention three.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, embodiment of the present invention is described further in detail below in conjunction with accompanying drawing.
Embodiment one
Please refer to Fig. 1, it shows the method flow diagram of the method for obtaining network data that the embodiment of the present invention one provides.This method of obtaining network data comprises:
Step 102 when needs obtain network data, judges whether to exist idle socket.
Under the traditional networking mode that adopts wap protocol, all can create socket at every turn when browser is asked network data and connect the gateway server that operator provides, when being China Mobile or CHINAUNICOM such as operator, when asking network data at every turn, browser all can connect the IP address: 10.0.0.172, port: 80; When operator is China Telecom for another example, when asking network data at every turn, browser all can connect the IP address: 10.0.0.200, port: 80.And browser to create the process that socket connects the gateway server that operator provides be more consuming time, for the process of this repetition being omitted as much as possible, at first can create the socket pond, this socket pond is used for storing the socket of the gateway server that in reusable connection, operator provides.In other words, can be at first realize in other words a socket pond mechanism in browser in terminal, for successfully connecting the socket of upper gateway, it is not closed after current connection is finished using at once, but put it in the middle of the socket pond, and it is labeled as idle so that multiplexing.When browser need to obtain network data, can at first judge whether there is idle socket in the socket pond.Certainly, also can take other storage mode to store the socket that these are connected and fixed gateway.
Step 104 if there is idle socket, adopts idle socket to obtain network data.
If browser is judged and is had idle socket in the socket pond, the socket that this is idle is labeled as and uses, and utilize this socket that is using directly to send connection request, thereby do not need to repeat " create socket, and connect gateway " this process.
In sum, the method of obtaining network data that provides in the present embodiment is by carrying out multiplexing to the socket that has created, saved the process of more " create Socket and also connect gateway " consuming time in the prior art, all carry out once the step of " create Socket and connect gateway " at every turn when making browser not need to obtain network data, thereby can realize at faster speed obtaining of network data.
Embodiment two
Please refer to Fig. 2, it shows the method flow diagram of the method for obtaining network data that the embodiment of the present invention two provides.This method of obtaining network data comprises:
Step 201 is pre-created the socket pond that is connected and fixed the socket of gateway for storage.
At first need to create the socket pond, this socket pond is used for storing the socket of the gateway server that in reusable connection, operator provides, and described residential gateway can be the IP address that CHINAUNICOM or China Mobile provide: 10.0.0.172, port: 80; Can be also the IP address that China Telecom provides: 10.0.0.200, port: 80, then or other gateway of providing of other national Internet service provider.In other words, at first realize in other words a socket pond mechanism in browser in terminal, for successfully connecting the socket of upper gateway, it is not closed after current connection is finished using at once, but put it in the middle of the socket pond, and it is labeled as idle so that multiplexing.
Step 202 when browser need to obtain network data, judges whether there is idle socket in the socket pond; If so, enter step 203; If not, enter step 204.
Step 203, if judge and have idle effectively socket in the socket pond, the socket that this is idle is labeled as and uses, then utilize this socket that is using directly to send connection request, thereby do not need to repeat " create socket, and connect gateway " this process.
Step 204, do not have idle effectively socket in the socket pond if judge, create new socket according to traditional approach, the new socket that creates will be marked as and use, then utilize described new socket to send connection request, to obtain network data.If create unsuccessfully, enter step 205.
Step 205 if create unsuccessfully, is returned to failure information.
Step 206 utilizes in socket that being designated in step 203 using or step 204 the new socket that creates to complete data interaction, when using after socket obtains Network Data Capture, enters step 207.
Step 207 judges that this socket is socket or the new socket that creates in the socket pond, if the socket in the socket pond enters step 208; If the new socket that creates enters step 209.
Step 208 is labeled as the free time with this socket that is arranged in the socket pond.
Step 209, the socket that will newly create from step 104 and finish using is labeled as the free time, and puts into the socket pond.
When browser needs to obtain network data again, return to step 202; When the browser long period is not all obtained network data, enter step 210.
Step 210 judges whether the free time of socket idle in the socket pond surpasses reservation threshold, if so, closes this socket and it is removed from the socket pond.
The gateway that provides due to operator generally all can arrange a time-out time, if after the socket in the socket pond connects gateway, a very long time is all without any operation, gateway can initiatively be closed this network connection so, have corresponding signal send to browser this moment, and browser need to cut out corresponding socket and it was removed from the socket pond this moment.
In sum, the method of obtaining network data that provides in the present embodiment is by carrying out multiplexing to the socket that has created, saved the process of more " create Socket and also connect gateway " consuming time in the prior art, all carry out once the step of " create Socket and connect gateway " at every turn when making browser not need to obtain network data, thereby can realize at faster speed obtaining of network data.Simultaneously, by the mechanism that the socket after overtime is removed, make on the one hand in the socket pond and can not have invalid socket; On the other hand, the socket in the socket pond can be not cumulative, and cause occuring in the socket pond situation of spill-over.
Embodiment three
Please refer to Fig. 3, it shows the block diagram of the device that obtains network data that the embodiment of the present invention three provides.This device that obtains network data comprises that socket pond 310, socket administration module 320, socket use module 330 and socket creation module 340.
Socket pond 310 is used for the socket that storage is connected and fixed gateway.Simply, can realize in other words a socket pond mechanism in browser in terminal, for the socket that successfully connects the gateway server that operator provides, after finishing using, current connection it is not closed at once, but put it in the middle of socket pond 310, and it is labeled as idle so that multiplexing.
Socket administration module 320 is used for when browser need to obtain network data, judge the socket that whether has the free time in socket pond 310.Socket administration module 320 can specifically include socket indexing unit 322, as shown in Figure 4.If there are idle sockets in socket administration module 320 judgement, socket indexing unit 322 can be labeled as socket that should the free time and use, and this is marked as the socket that is using transfers to socket and use module 330 to use.If there is not idle socket in 320 judgements of socket administration module, socket administration module 320 notice socket creation modules 340 create new socket.
Socket uses module 330 to be designated by socket administration module 320 socket that is using for utilization and sends connection request to complete the process of obtaining network data.
Socket creation module 340 is used for creating new socket, and then socket uses module 330 can also utilize the new socket of socket creation module 340 establishments to send connection request, to obtain network data.If it is unsuccessful that socket creation module 340 creates new socket, socket creation module 340 is returned to failure.
When socket use module 330 adopt a socket obtain network data complete after, socket administration module 320 can also specifically include socket judging unit 324, socket judging unit 324 is used for socket or the new socket that creates of socket creation module 340 that socket that the judgement socket uses module 330 to finish using is socket pond 310, if the socket in the socket pond, socket indexing unit 322 continues this socket is labeled as the free time; If the new socket that creates, this new socket that is created by socket creation module 340 is put into socket pond 310, and be labeled as the free time by socket indexing unit 322.
Socket administration module 320 can also include overtime judging unit 326 and socket removes unit 328, whether free time of socket that 326 judgements of overtime judging unit are arranged in the free time in socket pond 310 surpasses reservation threshold, if so, socket remove unit 328 be used for closing this after overtime socket and it 310 is removed from the socket pond.
In sum, the device that obtains network data that provides in the present embodiment is by carrying out multiplexing to the socket that has created, saved the process of more " create Socket and also connect gateway " consuming time in the prior art, all carry out once the step of " create Socket and connect gateway " at every turn when making browser not need to obtain network data, thereby can realize at faster speed obtaining of network data.
Need to prove: when the device that obtains network data that above-described embodiment provides is described in this paper embodiment, only the division with above-mentioned each functional module is illustrated, in practical application, can as required above-mentioned functions be distributed and be completed by different functional modules, the internal structure that is about to device is divided into different functional modules, to complete all or part of function described above.In addition, the device that obtains network data that above-described embodiment provides belongs to same design with the embodiment of the method for obtaining network data, and its specific implementation process sees embodiment of the method for details, repeats no more here.
One of ordinary skill in the art will appreciate that all or part of step that realizes above-described embodiment can complete by hardware, also can come the relevant hardware of instruction to complete by program, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be read-only memory, disk or CD etc.
The above is only preferred embodiment of the present invention, and is in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, is equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (12)

1. a method of obtaining network data, is characterized in that, described method comprises:
When needs obtain network data, judge whether to exist idle socket;
If have idle socket, adopt the socket of described free time to obtain network data.
2. the method for obtaining network data according to claim 1, is characterized in that, described judge whether to exist idle socket after, also comprise:
If there is no idle socket, create new socket;
Adopt described new socket to send connection request, to obtain network data.
3. the method for obtaining network data according to claim 1 and 2, is characterized in that, described judge whether to exist idle socket before, also comprise:
Be pre-created the socket pond that is connected and fixed the socket of gateway for storage;
Describedly judge whether to exist idle socket specifically to comprise:
Judge and whether have idle socket in described socket pond.
4. the method for obtaining network data according to claim 3, is characterized in that, the socket of described described free time of employing obtains network data and specifically comprises:
The socket of described free time is labeled as uses;
Adopt the described socket that is using that is marked as to send connection request, to obtain network data.
5. the method for obtaining network data according to claim 3, is characterized in that, the employing socket also comprises after obtaining network data:
Judge that described socket is socket or the new socket that creates in described socket pond;
If the socket in described socket pond is labeled as the free time with described socket;
If the new socket that creates, the socket with described new establishment is labeled as the free time, and puts into described socket pond.
6. the method for obtaining network data according to claim 3, is characterized in that, described method also comprises:
Whether the free time that judges the socket of the free time in described socket pond surpasses reservation threshold;
If so, close the socket of described free time and it is removed from described socket pond.
7. a device that obtains network data, is characterized in that, it comprises:
The socket administration module is used for when needs obtain network data, judges whether to exist idle socket;
Socket uses module, is used for adopting the socket of described free time to obtain network data when there is idle socket in described socket administration module judgement.
8. obtain according to claim 7 the device of network data, it is characterized in that, the described device that obtains network data also comprises the socket creation module;
Described socket creation module is used for creating new socket when there is not idle socket in described socket administration module judgement;
Described socket uses module, also is used for adopting described new socket to send connection request, to obtain network data.
9. the according to claim 7 or 8 described devices that obtain network data, is characterized in that, the described device that obtains network data also comprises:
The socket pond is used for the socket that storage is connected and fixed gateway;
Described socket administration module is used for judging whether described socket pond exists idle socket.
10. the device that obtains network data according to claim 9, is characterized in that, described socket administration module specifically comprises: the socket indexing unit;
Described socket indexing unit is labeled as for the socket with the described free time and uses;
Described socket uses module, is used for adopting the described socket that is using that is marked as to send connection request, to obtain network data.
11. the device that obtains network data according to claim 10 is characterized in that, described socket administration module also comprises: the socket judging unit;
Described socket judging unit is used for described socket and uses module to adopt after socket obtains network data, judge that described socket is socket in described socket pond or the socket of the new establishment of described socket creation module;
Described socket indexing unit also is used for when the described socket of described socket judgment unit judges is the socket in described socket pond, it being labeled as the free time;
Described socket indexing unit also is used for when the described socket of described socket judgment unit judges is the new socket that creates of described socket creation module, and the socket with described new establishment is labeled as the free time, and puts into described socket pond.
12. the device that obtains network data according to claim 11 is characterized in that, described socket administration module also comprises: overtime judging unit and socket remove the unit;
Described overtime judging unit is used for judging whether free time of socket of the free time in described socket pond surpasses reservation threshold;
Described socket removes the unit, and the free time of socket that is used for the free time in the described socket of described overtime judgment unit judges pond is when surpassing reservation threshold, closes described socket and it is removed from described socket pond.
CN2011104181074A 2011-12-14 2011-12-14 Method and device of obtaining network data Pending CN103166994A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2011104181074A CN103166994A (en) 2011-12-14 2011-12-14 Method and device of obtaining network data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2011104181074A CN103166994A (en) 2011-12-14 2011-12-14 Method and device of obtaining network data

Publications (1)

Publication Number Publication Date
CN103166994A true CN103166994A (en) 2013-06-19

Family

ID=48589732

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2011104181074A Pending CN103166994A (en) 2011-12-14 2011-12-14 Method and device of obtaining network data

Country Status (1)

Country Link
CN (1) CN103166994A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106411907A (en) * 2016-10-13 2017-02-15 广西咪付网络技术有限公司 Data transmission method and system
WO2018045724A1 (en) * 2016-09-09 2018-03-15 中国互联网络信息中心 Dns query forwarding method
CN108121598A (en) * 2016-11-29 2018-06-05 中兴通讯股份有限公司 Socket buffer resource management and device
CN112261094A (en) * 2020-10-10 2021-01-22 厦门网宿有限公司 Message processing method and proxy server

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6862276B1 (en) * 2000-03-30 2005-03-01 Qualcomm Incorporated Method and apparatus for a mobile station application to receive and transmit raw packetized data
CN101304373A (en) * 2008-06-25 2008-11-12 中兴通讯股份有限公司 Method and system for implementing high-efficiency transmission chunk data in LAN
CN101421702A (en) * 2006-04-26 2009-04-29 日本电信电话株式会社 Load control device and its method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6862276B1 (en) * 2000-03-30 2005-03-01 Qualcomm Incorporated Method and apparatus for a mobile station application to receive and transmit raw packetized data
CN101421702A (en) * 2006-04-26 2009-04-29 日本电信电话株式会社 Load control device and its method
CN101304373A (en) * 2008-06-25 2008-11-12 中兴通讯股份有限公司 Method and system for implementing high-efficiency transmission chunk data in LAN

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018045724A1 (en) * 2016-09-09 2018-03-15 中国互联网络信息中心 Dns query forwarding method
CN106411907A (en) * 2016-10-13 2017-02-15 广西咪付网络技术有限公司 Data transmission method and system
CN108121598A (en) * 2016-11-29 2018-06-05 中兴通讯股份有限公司 Socket buffer resource management and device
CN112261094A (en) * 2020-10-10 2021-01-22 厦门网宿有限公司 Message processing method and proxy server
CN112261094B (en) * 2020-10-10 2023-07-21 厦门网宿有限公司 Message processing method and proxy server

Similar Documents

Publication Publication Date Title
CN103812728B (en) A kind of network diagnosis method, system and router
CN102833323B (en) Method and system for remote control of controlled terminal by server
CN103079286A (en) Method and device for intelligently disconnecting wifi (wireless fidelity) hot points
CN110430238A (en) Long connection management method, apparatus, equipment and computer readable storage medium
CN102148838B (en) Web authentication method, network equipment and Web authentication system
CN104469970B (en) A kind of method and apparatus reconnecting data network
CN102891877A (en) Online processing system and method for implementing terminal application
CN104144185A (en) Data communication method, device and terminal
CN103139018B (en) Network card status monitoring under a kind of modulation integral system and TCP communication method
CN101801062A (en) Mobile terminal and network access method thereof
CN103166994A (en) Method and device of obtaining network data
CN109981360A (en) Internet of things equipment website activating method, device, system and storage medium
CN113746821A (en) Intelligent device control method and device, storage medium and electronic device
CN103220283A (en) Method, equipment and system for network sharing
CN101635633A (en) Active instant conversation method based on web page access request
CN101888308B (en) Method for realizing integrated management of multi-board embedded device
CN103729440B (en) A kind of method and device of access website
CN103051484B (en) Session service processing method, system and Session Border Controll
CN201608728U (en) Remote booting system
CN109600278A (en) A kind of data communications method, device, equipment and medium
CN103297584B (en) A kind of acquisition method, system and mobile terminal remaining the air time
CN101764701A (en) Network management system
CN110413322A (en) A kind of server network interface management method, system and baseboard management controller
CN101917307A (en) System, method and test device for testing maximum number of PPP connection
CN105163336A (en) Method and system for optimizing stability of wireless network

Legal Events

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

Application publication date: 20130619