Link to home
Start Free TrialLog in
Avatar of dannyguindi
dannyguindi

asked on

byte-by-byte metering

Hi experts,

I have a CGI (written in C++) that a user calls to download a file.  When the script executes, it streams the file back to the user.  I would like to know how I can verify if the download was successfull.  I have read about byte-by-byte metering but I don't know how to implement this.

Can anyone help?

Thanks,

dannyguindi
Avatar of dannyguindi
dannyguindi

ASKER

nobody know how to do this?
HTTP transactions take place over TCP sockets. TCP offers a reliability assurance: if the socket reports that the last byte of the file has been transmitted, then it has been acknowledged as received by the peer at the other end. Most of the time, this level of assurance is adequate to know that the download was successful.

To get an even greater degree of assurrance, you would need an additional exchange between the browser and server, perhaps even a dialog with the user. For instance, you could use an onSubmit routine to request the download _before_ doing the submit action. The arrival of the second request could be interpreted to mean that the download action completed successfully. A size or checksum of the downloaded file might even be included.
I don't understand what you mean by an exchange between the server and the browser.  When a user call my CGI script, it prompts hime to save the file or open it, like any other download.  If the user selects to save it, there is no other interaction between my script and the user.  who would be making the second call to my script to verify that the download completed successfully?

Any C code would be mostly helpful...

(increasing points to 150)
I'm not a JavaScript programmer, so I don't know that this can be done. But it certainly cannot be done solely on the server side, which is why you are having a hard time visualizing what the CGI code would look like.

In my primitive vision, the onSubmit routine, client-side, would do something like:

  dl_window = window.open
  dl_window.location = dl_file_URL

then wait around a short while for the download to complete, then ask the user to confirm( ) the download was successful, and only then submit the underlying form.



I don't want to depend on the user confirming the download.  If the user doesn't confirm, then I have the same problem I had before!

Increasing points to 200...
This question is now old enough that increasing the points is unlikely to attract additional attention. I suggest that you ask in Community Support to close this question (I think my responses are worth PAQing) and refund your points. You can then ask again in a way that more clearly sets out what you are attempting to do, what solutions you've already considered and rejected, and any other constraints you have on what you'll accept as a solution.

I still think that there is no straightforward solution that meets all of your criteria. To do exactly what you ask for would involve a violation of the security model the web browser implements to ensure that a web site cannot read an arbitrary file from the user's computer. But perhaps someone else can think of a slight weakening of what you want that will come close enough to fulfilling your goal.
ok, let me see if I can explain this better before I ask to close the question.

Assume I have a software product that I want to sell.  Once a person pays for it, I want to allow him to download it, but only ONCE.  If something fails during the download I want to allow the user to try to download it again.  But, I don't want anybody telling me that the download didn't work when in fact it did, and they are just trying to get a free copy of my software.  That's why I want to check if the download completes successfully without asking the user.

Does this make any more sense?  I know there are companies that do this, and I would like to know how.

Thanks.
If the download succeeds, a dishonest customer only has to copy the download to make extra copies. I'll go back to my original suggestion: once the 'write' call for the socket reports the last byte of the file has been transmitted, you can assume the download has succeeded.

I am still hoping for some help on this matter!   Increasing points...
I don't have any more ideas to help you.

Increasing the points is unlikely to attract new notice to a question that now appears on the second page of the question list for this section. I'll recommend again that you ask a new question. It could be a question that merely points back to this one or, better, one that is self-contained and outlines your whole problem.

You can ask in

https://www.experts-exchange.com/Community_Support/

to have this question PAQed and your points refunded (I have no objection to you getting all of your points back on this one).
Thanks, I will do just that.
I recommend PAQ, refund, as mentioned earlier.

Dannyguindi, you were going to ask this again, right?

yes, I am going to update and repost this question.
ASKER CERTIFIED SOLUTION
Avatar of Lunchy
Lunchy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial