Summary of the invention
Data verification method and server are provided in the embodiment of the invention, solving the correctness that caching server in the prior art can't the verification fragment data, thereby can't provide to the user problem of service when causing having bad fragment data in the cache resources.
For addressing the above problem, the technical scheme that the embodiment of the invention provides is as follows:
First aspect provides a kind of data verification method, and described method comprises:
Server sends the fragment data of the PT resource of described client-requested to the client that connects;
Record the Download Info of the fragment data of described client-requested;
When judging that described client is unusual and disconnect with being connected of described server, will not download the fragment data that successful fragment data is defined as mistake according to described Download Info.
In the possible implementation of the first of first aspect, described server sends to the client that connects before the fragment data of PT resource of described client-requested, also comprises:
Server sends the fragment data tabulation to the client of described connection, comprises the sign of the fragment data of buffer memory on the described server in the described fragment data tabulation;
Receive the fragment data request message that described client sends, comprise the sign of the fragment data of described client-requested in the described fragment data request message.
In conjunction with first aspect, or the possible implementation of the first of first aspect, in the possible implementation of the second of first aspect, the Download Info of the fragment data of the described client-requested of described record comprises:
Record the requested number of times of fragment data of described client-requested.
In conjunction with first aspect, or the possible implementation of the first of first aspect, in the third possible implementation of first aspect, the Download Info of the fragment data of the described client-requested of described record comprises:
Record the requested number of times of fragment data of described client-requested, and record the request results of the fragment data of described client-requested, the request results of wherein said fragment data is initially not to be finished, when receive request fragment data success that described client returns finish message the time, the request results of described fragment data is set to finish.
In conjunction with first aspect, or the possible implementation of the first of first aspect, or the possible implementation of the second of first aspect, or the third possible implementation of first aspect, in the 4th kind of possible implementation of first aspect, the unusual disconnection of the described client of described judgement is connected with described server, comprising:
When described client disconnects with being connected of described server, judge whether to receive the download that described client sends and finish notification message, it is the message that the backward described server of all fragment datas of described client success download request returns that notification message is finished in described download;
When not receiving described download and finish notification message, determine that described client is unusual to disconnect and being connected of described server.
In conjunction with first aspect, or the possible implementation of the first of first aspect, or the possible implementation of the second of first aspect, or the third possible implementation of first aspect, or the 4th kind of possible implementation of first aspect, in the 5th kind of possible implementation of first aspect, the successful fragment data of not downloading that records in the described Download Info is defined as wrong fragment data, comprising:
Search the Download History of each fragment data in the described Download Info, comprise the request number of times of each fragment data in the described Download History, and/or request results;
When existing request number of times to surpass once fragment data in the described Download History, determine that described fragment data is wrong fragment data;
In described Download History, exist request number of times for once, and the described request result is when being uncompleted fragment data, determines that described fragment data is wrong minute fragment data.
In conjunction with first aspect, or the possible implementation of the first of first aspect, or the possible implementation of the second of first aspect, or the third possible implementation of first aspect, or the 4th kind of possible implementation of first aspect, or the 5th kind of possible implementation of first aspect, in the 6th kind of possible implementation of first aspect, described method also comprises:
Server is deleted the fragment data of described mistake;
In the remaining fragment data except the fragment data of described deletion on the described server, when the fragment data of being crossed by client-requested is arranged not, connect next client;
Repeat described server sends the step of fragment data from the PT resource of described client-requested to the client that connects, until all fragment datas on the described server are all by the client-requested mistake.
Second aspect provides a kind of server, and described server comprises:
Transmitting element is for the fragment data that sends the PT resource of described client-requested to the client that connects;
Record cell records the Download Info of the fragment data of the described client-requested that described transmitting element sends;
Judging unit is used for judging whether described client disconnects and being connected of described server unusually;
Determining unit is used for will not downloading the fragment data that successful fragment data is defined as mistake when the described client of described judgment unit judges is unusual when disconnecting with being connected of described server according to the Download Info of described recording unit records.
In the possible implementation of the first of second aspect, described transmitting element also is used for sending the fragment data tabulation to the client of described connection, comprises the sign of the fragment data of buffer memory on the described server in the described fragment data tabulation;
Described server also comprises:
Receiving element is used for receiving the fragment data request message that described client sends, and comprises the sign of the fragment data of described client-requested in the described fragment data request message.
In conjunction with second aspect, or the possible implementation of the first of second aspect, in the possible implementation of the second of second aspect,
Described record cell, the concrete requested number of times of fragment data that is used for recording described client-requested, perhaps, record the requested number of times of fragment data of described client-requested, and record the request results of the fragment data of described client-requested, the request results of wherein said fragment data is initially not to be finished, when receive request fragment data success that described client returns finish message the time, the request results of described fragment data is set to finish.
In conjunction with second aspect, or the possible implementation of the first of second aspect, or the possible implementation of the second of second aspect, in the third possible implementation of second aspect,
Described judging unit, concrete being used for when being connected of described client disconnection and described server, judge whether to receive the download that described client sends and finish notification message, it is the message that the backward described server of all fragment datas of described client success download request returns that notification message is finished in described download; When not receiving described download and finish notification message, determine that described client is unusual to disconnect and being connected of described server.
In conjunction with second aspect, or the possible implementation of the first of second aspect, or the possible implementation of the second of second aspect, or the third possible implementation of second aspect, in the 4th kind of possible implementation of second aspect,
Described determining unit specifically for the Download History of searching described each fragment data of Download Info, comprises the request number of times of each fragment data in the described Download History, and/or request results; When existing request number of times to surpass once fragment data in the described Download History, determine that described fragment data is wrong fragment data; In described Download History, exist request number of times for once, and the described request result is when being uncompleted fragment data, determines that described fragment data is wrong minute fragment data.
In conjunction with second aspect, or the possible implementation of the first of second aspect, or the possible implementation of the second of second aspect, or the third possible implementation of second aspect, or the 4th kind of possible implementation of second aspect, in the 5th kind of possible implementation of second aspect, also comprise:
Delete cells is used for deleting the fragment data of the definite mistake of described determining unit;
Linkage unit is used for when the remaining fragment data except the fragment data of described delete cells deletion on the described server, when the fragment data of being crossed by client-requested is arranged not, connects next client;
Performance element, be used for after described linkage unit connects client, trigger described transmitting element and repeat the fragment data that described client to connecting sends the PT resource of described client-requested, until all fragment datas on the described server are all by the client-requested mistake.
The third aspect provides a kind of server, and described server comprises: communication bus, network interface, memory and processor, wherein,
Described communication bus is used for connecting described network interface, memory and processor;
Described network interface is used for connecting the client that accesses described server;
Described memory is used for preserving the fragment data of PT resource, and the Download Info of fragment data;
Described processor, be used for sending to the client that connects by described network interface the fragment data of the PT resource of described client-requested, the Download Info of the fragment data of described client-requested is recorded to described memory, and when judging that described client is unusual and disconnect with being connected of described server, will not download the fragment data that successful fragment data is defined as mistake according to the Download Info of preserving in the described memory.
In the possible implementation of the first of the third aspect, described processor, also be used for by the client transmission fragment data tabulation of described network interface to described connection, the sign that comprises the fragment data of buffer memory on the described server in the described fragment data tabulation, and receive the fragment data request message that described client sends, comprise the sign of the fragment data of described client-requested in the described fragment data request message.
In conjunction with the third aspect, or the possible implementation of the first of the third aspect, in the possible implementation of the second of the third aspect, described processor, concrete being used for is recorded to described memory with the requested number of times of the fragment data of described client-requested, perhaps, the request results of the fragment data of the requested number of times of the fragment data of described client-requested and described client-requested is recorded to described memory, the request results of wherein said fragment data is initially not to be finished, when receive request fragment data success that described client returns finish message the time, the request results of described fragment data is set to finish.
In conjunction with the third aspect, or the possible implementation of the first of the third aspect, or the possible implementation of the second of the third aspect, in the third possible implementation of the third aspect, described processor, also be used for from the fragment data of the described mistake of described memory deletion, and in the remaining fragment data except the fragment data of described deletion on the described server, when the fragment data of being crossed by client-requested is arranged not, connect next client, repeat the fragment data that described client to connecting sends the PT resource of described client-requested, until all fragment datas on the described server are all by the client-requested mistake.
Server sends the fragment data of described client-requested in the embodiment of the invention to the client that connects, and record the Download Info of the fragment data of described client-requested, when judging that described client is unusual and disconnect with being connected of described server, will not download the fragment data that successful fragment data is defined as mistake according to described Download Info.Use the embodiment of the invention, because client can obtain the cryptographic Hash of resource data, and utilize the cryptographic Hash of resource data that fragment data is carried out verification, therefore server can be before formal issue resource, by be connected mutual between the client, utilize fragment data that client is asked whether to download the fragment data that successful result determines the mistake that exists in the resource, thereby can again ask correct fragment data or the fragment data of deletion error, so that there is not the fragment data of mistake in the resource of issuing, guarantee that client can download to correct resource, improve the service quality of server.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is carried out clear, complete description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
Referring to Fig. 1, be an embodiment flow chart of data verification method of the present invention, this embodiment is from the process of the mutual data of description verification between server and the client that is connected:
Step 101: server sends the fragment data of the PT resource of described client-requested to the client that connects.
In the embodiment of the invention, server crawl and the protocol-dependent critical packet of BT are to obtain the PT resource.For example, server obtains the information of the PT resource that is published and the information of asking the client of this PT resource by crawl and the mode of the protocol-dependent critical packet of BT.Server with asked the client of this PT resource to connect to obtain the above-mentioned PT resource that is published.Concrete, the server crawl is used for obtaining the PT resource, comprises the resource Hash, i.e. infoHash, value, GET ANNOUNCE packet, and the BT HandShake packet that is used for request PT resource that sends of crawl BT client.Then, the critical packet that server grabs by analysis, i.e. GET ANNOUNCE packet and BTHandShake packet, the tabulation of setting up the corresponding relation of infoHash and PEER.Server can further record the requested number of times of PT resource corresponding to each infoHash, when the access times of certain PT resource reach preset value, connects to obtain this PT resource with PEER corresponding to this PT resource in server and the tabulation.
In an implementation of the present embodiment, server sends the fragment data tabulation to the client of described connection, comprises the sign of all fragment datas of buffer memory on the described server in the described fragment data tabulation; Server receives described client according to the fragment data request message that described fragment data tabulation sends, and comprises the sign of described client fragment data of selection from described fragment data tabulation in the described fragment data request message; Server sends to described client with the fragment data corresponding with the sign of the fragment data of described selection.
Step 102: the Download Info that records the fragment data of described client-requested.
In an optional implementation of the present embodiment, the request number of times that comprises the fragment data that client is asked in the Download Info of the fragment data of described client-requested, the initial value of this request number of times is 0, after server received the fragment data request message that described client sends, the request number of times of the fragment data that described fragment data request message is asked added 1.In another optional implementation of the present embodiment, comprise the request number of times of the fragment data that client is asked and the request results of described fragment data in the Download Info of the fragment data of described client-requested; The initial value of this request number of times is 0, and after server received the fragment data request message that described client sends, the request number of times of the fragment data that described fragment data request message is asked added 1; This request results is initially not to be finished, when server receive request fragment data success that described client returns finish message the time, the request results of described fragment data is set to finish.
Step 103: when judging that described client is unusual and disconnect with being connected of described server, will not download the fragment data that successful fragment data is defined as mistake according to described Download Info.
In an implementation of the present embodiment, when server receive that client sends disconnect message the time, server determines that this client has disconnected and being connected of this server, server judged whether to receive the download that described client sends and finished notification message this moment, it is the message that the backward described server of all fragment datas of described client success download request returns that notification message is finished in described download, when server did not receive described download and finishes notification message, server was determined that described client is unusual and is disconnected and being connected of described server.
In above-mentioned steps 102, comprise in the Download Info of fragment data of the described client-requested of record in the situation of request number of times of the fragment data that client is asked, when server is judged that described client is unusual and is disconnected with being connected of described server, the Download History of each fragment data in the Download Info of whois lookup record, the request number of times that comprises each fragment data in the described Download History, in described Download History, exist request number of times to surpass pre-determined number, for example once, fragment data the time, determine that described fragment data is wrong fragment data; In above-mentioned steps 102, comprise in the Download Info of fragment data of the described client-requested of record in the situation of request results of the request number of times of the fragment data that client is asked and described fragment data, in described Download History, exist request number of times to surpass pre-determined number, for example once, and when described request result was uncompleted fragment data, server determined that described fragment data is wrong fragment data.
In the embodiment of the invention, the client that need to download the PT resource can obtain the seed file of PT resource, by the content Hash value in this seed file, whether the fragment data of the PT resource of can verification downloading is correct, therefore server is getting access to the PT resource, and before formally issuing this PT resource to client, can adopt above-described embodiment, by and be connected to mutual between the client of server, utilize fragment data that client is asked whether to download the fragment data that successful result determines the mistake that exists in the PT resource, thereby can again ask correct fragment data or the fragment data of deletion error, so that there is not the fragment data of mistake in the resource of issuing, guarantee that client can download to correct resource, improve the service quality of server.
Referring to Fig. 2, be another embodiment flow chart of data verification method of the present invention, this embodiment is by connecting the detailed process of a plurality of clients to realize all fragment datas of resource to be released on the caching server are carried out verification:
Step 201: caching server enters the resource checksum pattern by after obtaining resource to be released without the kind mode.
In the present embodiment, caching server can be specially the PT resource by the resource of obtaining without the kind mode.In the embodiment of the invention, server crawl and the protocol-dependent critical packet of BT are to obtain the PT resource.For example, server obtains the information of the PT resource that is published and the information of asking the client of this PT resource by crawl and the mode of the protocol-dependent critical packet of BT.Server with asked the client of this PT resource to connect to obtain the above-mentioned PT resource that is published.Concrete, the server crawl is used for obtaining the PT resource, comprises the resource Hash, i.e. infoHash, value, GET ANNOUNCE packet, and the BT HandShake packet that is used for request PT resource that sends of crawl BT client.Then, the critical packet that server grabs by analysis, i.e. GET ANNOUNCE packet and BT HandShake packet, the tabulation of setting up the corresponding relation of infoHash and PEER.Server can further record the requested number of times of PT resource corresponding to each infoHash, when the access times of certain PT resource reach preset value, connects to obtain this PT resource with PEER corresponding to this PT resource in server and the tabulation.
The PT resource is that the form according to fragment data manages and shares, for example, the PT resource of a 500MB, each fragment data size is 8MB, then this PT resource has 63 fragment datas.Before certain client issue PT resource, set up seed file for this PT resource first, when setting up seed file, need to calculate the content Hash value of each fragment data in the PT resource, all fragment datas content Hash value separately is included in the seed file.Except the content Hash value of fragment data, usually can also comprise the size of resource name, fragment data, the burst quantity of fragment data etc. in the seed file; The client that need to download this PT resource can obtain the seed file of PT resource, by the content Hash value in this seed file, whether the fragment data of the PT resource of can verification downloading is correct, for example, for a fragment data of downloading, can calculate the content Hash value of this fragment data, if the content Hash value of this fragment data that comprises in the content Hash value of this calculating and the seed file is identical, determine that then this fragment data download is correct, otherwise this fragment data is downloaded mistake.
In the embodiment of the invention, in order to reduce a plurality of clients simultaneously from same client downloads PT resource, cause the taking of the network bandwidth, can be by caching server by obtaining this PT resource from the client of issuing this PT resource first without the kind mode.Usually, when caching server is downloaded the PT resource, owing to can't obtain the seed file of PT resource, also just can't carry out verification to the fragment data of the PT resource downloaded by the content Hash value in the seed file, therefore in the embodiment of the invention caching server before formally issuing the PT resource to the client of PT resource to be downloaded, at first enter the resource checksum pattern, connect a small amount of client by caching server, utilize the seed file of the PT resource that these clients have had, the fragment data of the mistake that may exist in the PT resource to buffer memory on this caching server carries out verification, to be correct fragment data in the PT resource that guarantees finally to be issued to all clients that are connected to this caching server.
Referring to Fig. 2 B, be the caching server of application embodiment of the invention method and the configuration diagram between the client.
Step 202: caching server connects client.
Under the resource checksum pattern, caching server can connect a client.Caching server also can connect more than one client, the parallel data check that carries out of the client that caching server is connected with each.Below connect a client as an implementation of the example explanation embodiment of the invention take caching server.
Step 203: caching server sends the fragment data of described client-requested to the client that connects.
The resource provider of PT resource when caching server is downloaded the PT resource from resource provider, can obtain the sign of each fragment data of PT resource for forming each fragment data allocation identification of PT resource.Behind a client Connection Cache server, caching server can send to this client the fragment data tabulation of the PT resource of buffer memory, comprises the sign of all fragment datas in this fragment data tabulation, i.e. fragment data number; Client is after the fragment data tabulation, the fragment data that comprises in can tabulating according to self this fragment data of needs request, when the request fragment data, select the sign of a fragment data the sign of the fragment data that this client can be each time comprises from the fragment data tabulation, the sign of the fragment data selected is write the fragment data request message, and send to server; Server whenever receives a fragment data request message, according to the sign of the fragment data that comprises in this fragment data request message, the fragment data corresponding with sign this fragment data that get access to is sent to client.
In the present embodiment, suppose to comprise in the PT resource ten fragment datas, its sign is expressed as respectively burst 1, burst 2, burst 3, burst 4, burst 5, burst 6, burst 7, burst 8, burst 9, burst 10.After caching server enters checking mode, suppose wherein first three of first a client-requested fragment data of connection, be burst 1, burst 2 and burst 3, then this client selects a sign to be written in the fragment data request message each time from the sign of first three fragment data.
Step 204: caching server records the Download Info of the fragment data of described client-requested.
In this step, the particular content of the Download Info of caching server record is distinguished to some extent:
For example, some client is after the fragment data mistake that verification is asked by the fragment data request message, may repeat to send the fragment data request message, so caching server can be determined whether mistake of fragment data according to the transmission times of fragment data request message; During concrete operations, in the process of client by transmission fragment data request message requests fragment data, after caching server received the fragment data request message that this client sends, the request number of times of the fragment data that this fragment data request message is asked added 1.
Again for example, some client is after the fragment data that verification is asked by the fragment data request message is correct, can send the message of finishing that should fragment data to caching server, for example be have message in the BT agreement, and after verification fragment data mistake, do not return any message to caching server, also can not repeat to send the fragment data request message, so whether caching server can be finished message and determine whether fragment data is correct according to receiving; During concrete operations, when caching server receive request fragment data success that this client returns finish message the time, the request results of this fragment data is set to finish.
Wherein, when caching server receives the fragment data request message that client sends first for certain fragment data, can be with the index that is designated of the fragment data that comprises in this fragment data request message, set up the record list item of Download Info for this fragment data, record the request number of times of this fragment data by this record list item, perhaps record request number of times and the request results of this fragment data by this record list item.
As shown in table 1 below, the Download Info of first three fragment data of asking for first client of caching server record:
Table 1
The sign of fragment data |
Request number of times |
Request results |
Burst 1 |
1 |
have |
Burst 2 |
1 |
|
Burst 3 |
2 |
|
Above-mentioned table 1 only is exemplary description, and in actual applications, the each client that connects of caching server may only belong to a kind of in two types the client of above-mentioned example.
Step 205: when described client disconnects with being connected of described caching server, judge whether to receive the download that described client sends and finish notification message, if caching server receives the download of described client transmission and finishes notification message, then execution in step 209; If caching server does not receive the download of described client transmission and finishes notification message, then jump to step 206.
If client is being asked all fragment datas usually, and determine that these fragment datas all download when successful, can send a download to caching server and finish notification message, for example, to finish notification message be uninterested message in this download in the BT agreement.Send download finish notification message after, client can send one to caching server and disconnect message, disconnects and being connected of caching server.Asking when client in the process of fragment data, if the discovery request then also can send one to caching server and disconnect message to wrong fragment data, the active disconnection is connected with caching server.Caching server receives that client sends disconnect message after, can know client disconnected with caching server between be connected, for example, (English is Transmission Control Protocol based on transmission control protocol between caching server and client, be abbreviated as TCP) when connecting, this disconnects message is the FIN message.
Therefore, when client disconnects with being connected of caching server, caching server can judge whether to receive the download that this client sends and finish notification message, if receive to download and finish notification message, determine that then client is normal disconnection, and client its all required fragment datas have been asked; Do not finish notification message if receive to download, determine that then client is unusual disconnection, and client may also not asked its all required fragment datas.
Step 206: determining that described client is unusual disconnects and being connected of described caching server, and will not download the fragment data that successful fragment data is defined as mistake according to described Download Info.
Still first client that connects take caching server is as example, in conjunction with aforementioned table 1 as can be known, when caching server determine this client unusual disconnect with being connected of this caching server after, the Download Info of caching server look-up table 1 record, for example, record that can first search request number of times obtains wherein the 3rd the requested mistake twice of fragment data of burst 3 correspondences, determines that then the 3rd fragment data be the fragment data of mistake; Then record that can the search request result obtains wherein that the request number of times of second fragment data of burst 2 correspondences is 1, but does not return " have " message, determines that then second fragment data be the fragment data of mistake.
The present embodiment shows first client-requested cross its needed all fragment datas after, the unusual disconnection and being connected of caching server, in the practical application, certain client may be before not asked needed all fragment datas, when request just disconnects during to certain wrong fragment data and being connected of caching server, this embodiment of the invention is not limited.
Step 207: caching server is deleted the fragment data of described mistake.
Process by the abovementioned steps description, the client of caching server by connecting, can identify this client when unusual the disconnection, the fragment data of the mistake that comprises in the fragment data of having asked, so caching server can be deleted these wrong fragment datas.Behind the fragment data of deletion error, can again download these fragment datas, and the client by follow-up connection is carried out verification to these fragment datas and the fragment data of also not asking.
Step 208: judge in the remaining fragment data except the fragment data of described deletion, whether the fragment data of not crossed by client-requested is arranged, if the fragment data of not crossed by client-requested is arranged, then return step 202; If do not have the fragment data do not crossed by client-requested, then finish current flow process.
Still first client that connects take caching server is as example, check results in conjunction with aforementioned table 1, behind complete three fragment datas of this client-requested, also have seven fragment datas on the caching server not by verification, therefore caching server can be by connecting next client, to not carried out verification by the fragment data of verification, until on this caching server all fragment data all by verification.
In this step, caching server is after all fragment datas under this resource checksum pattern are all by client-requested, then finish the checking process under this resource checksum pattern, follow-up caching server can be downloaded deleted fragment data again, and reopen next time resource checksum pattern, checking procedure under the resource checksum pattern is consistent with the process of the present embodiment next time, do not repeat them here, until all fragment datas of buffer memory are all correct on the caching server, then caching server can the ending resource checking mode, the PT resource that is comprised of correct fragment data to the client issue.
Step 209: judge whether the fragment data do not crossed by client-requested if the fragment data of not crossed by client-requested is arranged, then to return step 202; If do not have the fragment data do not crossed by client-requested, then finish current flow process.
After notification message is finished in the download that receives the client transmission, determine that all fragment datas of client-requested all download successfully, therefore caching server is judged except downloading successful fragment data, whether also there is the fragment data of not crossed by client-requested, if still there is the fragment data of not crossed by client-requested, then can carry out verification to remaining fragment data by connecting next client, until on this caching server all fragment data all by verification.
As seen from the above-described embodiment, in the embodiment of the invention, the client that need to download the PT resource can obtain the seed file of PT resource, by the content Hash value in this seed file, whether the fragment data of the PT resource of can verification downloading is correct, therefore server is getting access to the PT resource, and before formally issuing this PT resource to client, can adopt above-described embodiment, by and be connected to mutual between the client of server, utilize fragment data that client is asked whether to download the fragment data that successful result determines the mistake that exists in the PT resource, thereby can again ask correct fragment data or the fragment data of deletion error, so that there is not the fragment data of mistake in the resource of issuing, guarantee that client can download to correct resource, improve the service quality of server.
Corresponding with the embodiment of data verification method of the present invention, the present invention also provides the embodiment of the server that is used for execution the method.
Referring to Fig. 3, be an embodiment block diagram of server of the present invention:
This server comprises: transmitting element 310, record cell 320, judging unit 330 and determining unit 340.
Wherein, transmitting element 310 is for the fragment data that sends the PT resource of described client-requested to the client that connects;
Record cell 320 is used for recording the Download Info of the fragment data of the described client-requested that described transmitting element 310 sends;
Judging unit 330 is used for judging whether described client disconnects and being connected of described server unusually;
Determining unit 340 is used for will not downloading the fragment data that successful fragment data is defined as mistake according to the Download Info that described record cell 320 records when described judging unit 330 is judged that described client is unusual and disconnected with being connected of described server.
Referring to Fig. 4, be another embodiment block diagram of server of the present invention:
This server comprises: transmitting element 410, receiving element 420, record cell 430, judging unit 440, determining unit 450, delete cells 460, linkage unit 470 and performance element 480.
Wherein, transmitting element 410 is used for sending the fragment data tabulation to the client of described connection, comprises the sign of the fragment data of buffer memory on the described server in the described fragment data tabulation;
Receiving element 420 is used for receiving the fragment data request message that described client sends, and comprises the sign of the fragment data of described client-requested in the described fragment data request message;
Described transmitting element 410 is also for the fragment data that sends the PT resource of described client-requested to the client that connects;
Record cell 430 records the Download Info of the fragment data of the described client-requested that described transmitting element 410 sends;
Judging unit 440 is used for judging whether described client disconnects and being connected of described server unusually;
Determining unit 450 is used for will not downloading the fragment data that successful fragment data is defined as mistake according to the Download Info that described record cell 430 records when described judging unit 440 is judged that described client is unusual and disconnected with being connected of described server.
Delete cells 460 is used for deleting the fragment data of the mistake that described determining unit 450 determines;
Linkage unit 470 is used for when the remaining fragment data except the fragment data of described delete cells 460 deletions on the described server, when the fragment data of being crossed by client-requested is arranged not, connects next client;
Performance element 480, be used for after described linkage unit 470 connects client, trigger described transmitting element 410 and repeat the fragment data that described client to connecting sends the PT resource of described client-requested, until all fragment datas on the described server are all by the client-requested mistake.
In an implementation of the present embodiment, described record cell 430, the concrete requested number of times of fragment data that is used for recording described client-requested, perhaps, record the requested number of times of fragment data of described client-requested, and record the request results of the fragment data of described client-requested, the request results of wherein said fragment data is initially not to be finished, when receive request fragment data success that described client returns finish message the time, the request results of described fragment data is set to finish.
In another implementation of the present embodiment, described judging unit 440, concrete being used for when being connected of described client disconnection and described server, judge whether to receive the download that described client sends and finish notification message, it is the message that the backward described server of all fragment datas of described client success download request returns that notification message is finished in described download; When not receiving described download and finish notification message, determine that described client is unusual to disconnect and being connected of described server.
In another implementation of the present embodiment, described determining unit 450 specifically for the Download History of searching described each fragment data of Download Info, comprises the request number of times of each fragment data in the described Download History, and/or request results; When existing request number of times to surpass once fragment data in the described Download History, determine that described fragment data is wrong fragment data; In described Download History, exist request number of times for once, and the described request result is when being uncompleted fragment data, determines that described fragment data is wrong minute fragment data.
Referring to Fig. 5, be another embodiment block diagram of server of the present invention:
This server comprises: communication bus 510, network interface 520, memory 530 and processor 540.
Wherein, described communication bus 510 is used for connecting described network interface 520, memory 530 and processor 540;
Described network interface 520 is used for connecting the client that accesses described server;
Described memory 530 is used for preserving the fragment data of PT resource, and the Download Info of fragment data;
Described processor 540, be used for sending to the client that connects by described network interface 510 fragment data of the PT resource of described client-requested, the Download Info of the fragment data of described client-requested is recorded to described memory 530, and when judging that described client is unusual and disconnect with being connected of described server, will not download the fragment data that successful fragment data is defined as mistake according to the Download Info of preserving in the described memory 530.
In an implementation of the present embodiment, described processor 540, also be used for by the client transmission fragment data tabulation of described network interface to described connection, the sign that comprises the fragment data of buffer memory on the described server in the described fragment data tabulation, and receive the fragment data request message that described client sends, comprise the sign of the fragment data of described client-requested in the described fragment data request message.
In another implementation of the present embodiment, described processor 540, concrete being used for is recorded to described memory with the requested number of times of the fragment data of described client-requested, perhaps, the request results of the fragment data of the requested number of times of the fragment data of described client-requested and described client-requested is recorded to described memory, the request results of wherein said fragment data is initially not to be finished, when receive request fragment data success that described client returns finish message the time, the request results of described fragment data is set to finish.
In another implementation of the present embodiment, described processor 540, also be used for from the fragment data of the described mistake of described memory deletion, and in the remaining fragment data except the fragment data of described deletion on the described server, when the fragment data of being crossed by client-requested is arranged not, connect next client, repeat the fragment data that described client to connecting sends the PT resource of described client-requested, until all fragment datas on the described server are all by the client-requested mistake.
As seen from the above-described embodiment, server sends the fragment data of described client-requested in the embodiment of the invention to the client that connects, and record the Download Info of the fragment data of described client-requested, when judging that described client is unusual and disconnect with being connected of described server, will not download the fragment data that successful fragment data is defined as mistake according to described Download Info.Use the embodiment of the invention, because client can obtain the cryptographic Hash of resource data, and utilize the cryptographic Hash of resource data that fragment data is carried out verification, therefore server can be before formal issue resource, by be connected mutual between the client, utilize fragment data that client is asked whether to download the fragment data that successful result determines the mistake that exists in the resource, thereby can again ask correct fragment data or the fragment data of deletion error, so that there is not the fragment data of mistake in the resource of issuing, guarantee that client can download to correct resource, improve the service quality of server.
The technology that those skilled in the art can be well understood in the embodiment of the invention can realize by the mode that software adds essential general hardware platform.Based on such understanding, the part that technical scheme in the embodiment of the invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the storage medium, such as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the present invention or embodiment.
Each embodiment in this specification all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses is difference with other embodiment.Especially, for system embodiment because its basic simlarity is in embodiment of the method, thus describe fairly simple, relevant part gets final product referring to the part explanation of embodiment of the method.
Above-described embodiment of the present invention does not consist of the restriction to protection range of the present invention.Any modification of within protection scope of the present invention, doing, be equal to and replace and improvement etc., all should be included within protection scope of the present invention.