Download a binary file using sockets without known length

Hi all

I am trying to download a binary (.exe) file using the socket, where the length of the file is not known. Please take a look at the code I use:

var readBin = socketBin.read ();

<-here's the code that checks the http Content-length header field

; If the field length of the content is available, then I will use it to download files, otherwise continue with the following code-->

"pBar.reset (download plugin..", null); pBar.hit (readBin.length);

While (1)

{

binFil.write (readBin);     'binFil' is the file in which the uploaded file is written.

readBin = socketBin.read ();

pBar.hit (readBin.length);

If (socketBin.eof | readBin.length < = 0) {}

Break ;}

}

binFil.write (readBin);

binFil.close ();

socketBin.close ();

Problem is: I am able to download files within 10 seconds when the content length is known. But when the content length is not known, its about 1 and a half minute to download, also the progress bar gets hit for much of the time.

FYI: socket is opened in binary mode, file is downloaded correctly (even if it takes abt a minute). BTW Im using extendscript CS5.5

I am not able to understand where is the bug.

Hi, Srikanth:

Several points.

#1 during the validation of code, please use the web interface and the > icon and choose syntax highlighting > Java. Otherwise your code is simply too difficult to read and gets the poster.

#2 #1 apropos, your script, as written does not work, because this line:

url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$ 1/$2/$3/$4");

has an extra $ 1 space and should be this:

url=url.replace(/([a-z]*):\/\/([-\._a-z0-9A-Z]*)(:[0-9]*)?\/?(.*)/,"$1/$2/$3/$4");

Please take an extra moment to ensure that when ask you for help, you do so in a way that makes sense. Otherwise, it takes too much effort to help you, and it's frustrating.

#3 If equip them us your script by adding a line to the loop while():

            while (1)
            {
                binFil.write(readBin);
                readBin = socketBin.read();
                $.writeln(Date()+" Read "+readBin.length+" chars, eof is "+socketBin.eof);
                if(  readBin.length<=0){         break;}
            }

We get the output like this:

Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
Mon Jul 11 2011 12:06:56 GMT-0400 Read 1024 chars, eof is false
Mon Jul 11 2011 12:06:56 GMT-0400 Read 631 chars, eof is false
Mon Jul 11 2011 12:07:06 GMT-0400 Read 0 chars, eof is false
Result: undefined

So, we can reasonably conclude that the last reading at the end of the stream returns a short read when the other side blocks.

Unfortunately, this is clearly insufficient since you can get short readings all the time.

I don't know why you say we do not know the length of the file, HTTP, it provides you the Content Length of the response field.

But the easy answer is to get the server to close for you. It's easy enough, with connection: close. Why were specify you

Connection: keep-alive, what? :

            var requestBin =
            "GET /" + parsedURLBin.path + " HTTP/1.1\n" +
            "Host: " + parsedURLBin.address + "\n" +
            "User-Agent: InDesign ExtendScript\n" +
            "Accept: */*\n" +
            //"Connection: keep-alive\n\n";
            "Connection: close\n"+
            "\n";

This gives a nice tidy:

Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
Mon Jul 11 2011 12:26:19 GMT-0400 Read 1024 chars, eof is false
Mon Jul 11 2011 12:26:19 GMT-0400 Read 735 chars, eof is true
Mon Jul 11 2011 12:26:19 GMT-0400 Read 0 chars, eof is true

I suspect, you are better to use something like socketBin.read(64*1024) for a 64 k buffer size, but it doesn't seem to affect the on-the-wire protocol, so maybe its not so important.

If you do not want to answer on the server

Tags: InDesign

Similar Questions

  • How to download a large file using 4 G

    Whenever I have try and download a larger file on YouTube on wifi phone stops me and says that I need wifi to do this. It allows me to do using 4 G. How can I get to enable this?

    I had the problem to sending a video by selecting youtube my Gallery but after I downloaded a video using the youtube app, I am now able to download on youtube of the gallery. Thanks for your help.

  • I cannot download a .pdf file using Adobe Acrobat module 11.0.6.70. Disabling the add-on allows me to download the .pdf.

    I tried to download a .pdf file and open it with Adobe 11.0.6.70 module in FF 25.0.1 and received a message that the file has been damaged and cannot be repaired. I called the Technical Support of the site, and they asked that I have try with another browser download (ugh!) and the download worked. I returned and disabled the add-on Adobe in FF and the download worked in FF also. Don't know who developed the add-on, but one who did, left a bug in the process.

    HI central_texan,

    Please upgrade to the latest version of Firefox by going on the subject of Firefox from the Firefox menu. If download hangs at the last minute (just before reaching 100%), the cause may be an antivirus software that tries to parse the file and during this process the instance of Firefox crashes. It can also occur when the download is corrupted. What I want to know is in the system requirements, which means "Firefox Extended Support Release".

    To resolve the issue, try disabling the analysis as follows:

    1. In the address bar, type Subject: config and press enter. The subject: config "this might void your warranty!" warning page may appear.
    2. Click on I'll be careful, I promise!, to continue on the subject: config page. A list of parameters must appear
    3. Filter the list by typing in the search bar at top. Enter scanWhenDone. Now you should find the browser.download.manager.scanWhenDone preference.
    4. Double-click this preference to set the value to false.
    5. Then, try to download something and see if it still crashes.

    Please reply and let us know if this helped you!

  • Cannot download emails pdf files using Internet Explorer.

    Original title: Internet Explorer

    Outlook and Internet Explorer will not allow downloads even starting from the Microsoft Web Site.

    Will not download Zip, PDF file of email

    Can go to GOOGLE and open Outlook, and then it will download.

    Won't allow Bing become the home page.

    Just says cannot download.

    Microsoft should want to solve this problem.

    Hi Larry,

    Sorry for the late reply.

    To solve the problem with Internet Explorer and outlook.com downloads.

    I suggest to disable the Antivirus software on your computer and test the issue.

    When you disable Antivirus:

    Important note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.

    For most Antivirus programs, there is an icon next to the clock in the taskbar, you should be able click on icon and either be able to disable it from there or you can go into the options and disable it.

    Note: If the problem persists, you can activate your Antivirus program.

    You can also test the issuance by uninstall and then reinstall the Antivirus program.

    Note: Uninstall the antivirus before you that you saved the license key for this.

    Please follow the suggestion above and let us know the status of the issue.

  • Difficulties to download the .pdf file using Adobe 10 app "no connection not detected".

    Have enabled internet connection when you are connected to the web page and domain name when I try to download the .pdf forms, open app Adobe10 but file download transfer stalls saying unable to detect the internet connection? I am already connected, I don't understand

    file transfer download stalls saying unable to detect the internet connection? I am already connected, I don't understand

    A firewall can cause that.   For example the program tries to link may need to be allowed to pass through.

    ---

  • The 11g using uninstall tool to remove the old binary files?

    Hi all

    I know that with 11g, the preferred method for deleting old binary files is to use the uninstall tool (in/deinstall/of-install $11G_HOME). However, is it possible for me to remove the old binary files using this tool?

    For example, my 11g ORACLE_HOME (that is to say that I want to keep and use) is /opt/oracle/product/11.2.0.3/db

    And I have the following binary files on a particular database server:

    Oracle@myserver:/opt/Oracle/product > ls

    10.2 11.1 8.1.6.2 8.1.7.1 8.1.7.4 9.0.1.0 9.2.0.2 9.2.0.5 agent
    10.2.0.3 11.2.0.3 8.1.7.0 8.1.7.3 8.1.7.4.32 9.0.1.1 9.2.0.4 9.2.0.6

    As you can see, I have binary files dating back to before the beginning of time (8.1.6, nice) and I wish I could clean it carefully.

    I tried to uninstall (just under the checkonly, to ensure that it "sees" the old house) 10.2 binaries using the 11 g uninstall tool and got the following error:

    /opt/Oracle/product/11.2.0.3/DB/deinstall/deinstall-Accueil /opt/oracle/product/10.2/db - checkonly
    Verification of the required files must be treated and...
    Please wait...

    ERROR:-House does not have to be defined for a deinstall linking in an ORACLE_HOME.
    Uninstalling the current House is supposed to.

    Any thoughts? I absolutely don't want to uninstall the current home!

    Mark

    If you want to get rid of the old the ORACLE_HOME, then you must use the corresponding version of uninstall and must be run from the ORACLE_HOME.

    The best way to remove the ORACLE_HOME is to deattaching the old ORACLE_HOME with inventroy and remove this old House.

    /oui/bin/detachHome.sh
    
  • Reading a binary file - access error

    I am new to the discussion Forum OR and had a basic question on the use of Labview to read a binary file.

    For my application, I need Labview to collect a single value (pulse width) of a custom program that is written in C++. Currently, this value is stored in a temporary file of binary data. I'll run Labview and the custom program at the same time.

    Is it possible to read a binary file using Labview while the file is written by another program to? At the moment I get an access error. I use a binary code to read the library of example Labview base.

    Thanks for your suggestions!

    I'm surprised that Windows would let you copy of the file if the other program still has a lock on it.  How you try to open your file in LabVIEW now?  Maybe if you open the file with accesss unalterable, Windows will allow you to open it in LabVIEW.

    Yes, you can copy files in LabVIEW.  There are functions to copy under the palette file IO.  In addition, you can use a copy within the service system Exec command.

  • Need to download Skype whenever I use it

    Original title: Skype download

    I downloaded Skype. I use skpe without any problem. I sign when you are finished. However, if I want to use again, the app has disappeared and I have download it again in order to use, none of my partners have this problem.

    Help

    I use it on my personal computer. It appears in the program group AFTER download.

    I don't know what you mean when you refer to "click with the right button on the installation executable

    David

    You have to download Skype everywhere again whenever you need to use it. When you download Skype you download a Setup program that installs the program "Skype". When you download on your computer, it right with the right mouse button and click "run as Administrator".
    Releasing it's easy: with Windows | ActiveWin | Laptops | Microsoft MVP

  • How can I disable the auto-hide known file attachments, and why are still on the 10 internet pages where I have to download something if I use firefo

    How can I disable the auto-hide known file attachments and why are they always about 10 Web pages where I have to download something when I use mozila firefox?

    Windows computer

    Ignore the link of the player Shockwave that probably, you mustn't he compared to Flash player because it is barely used nowadays.

    FredMcD, you really need correct/update your clipboard for that.

    The downloadable Shockwave player version (not flashing) is 12.1.3.153 and not 15.0.0.152 as you can be confusing which version of the flashplayer reached before.

    Flash player is 15.0.0.189 and not 14.0.0.179 as you can see at https://www.adobe.com/software/flash/about/

    Flash player is used for good Flash videos like Youtube and Flash games in Shockwave player is little used compared to Flash, for things such as games and online learning tools.

    And please, don't say "I asked. It's the way it is displayed on the site"as you said last time in https://support.mozilla.org/en-US/questions/1026518 , because who says little about why you're wrong ad versions and calling Shockwave player, Shockwave Flash.

  • Download Helper - how to download and save files .wmv WITHOUT the video being downloaded reading on screen?

    Windows 7 Pro
    Latest Version of Firefox
    Latest Version of Download Helper
    Windows Media Player and VLC are installed

    When I download a video file (.wmv, usually) the video starts to play on the screen of the monitor prior to my being able to use Download Helper to download the video and save it on the hard drive. This generally translates the video stopping and playing and stopping the process of download because of the speed of download available. There is never any problem with the final download hard disk.

    Today I installed the latest version of Firefox and Download Helper on another computer.
    Windows 7
    Latest Version of Firefox
    Latest Version of Download Helper
    Windows Media Player (not) is installed

    Downloaded the same .wmv file you downloaded above and the video started to play on the screen of the monitor. Download Helper has allowed me to download the file on the disk hard WITHOUT constantly tuned to the video start/stop/start/stop etc.

    Which option (in which program) would allow playback of the video to be turned on and off all by downloading the .wmv file?

    Thank you.

    Once the download has started, you can go to another web page. The
    Download must be a separate function.

  • I downloaded ADE but then used without permission.  I now need to allow in order to transfer ebook on my ereader and not just read on my computer.

    I downloaded ADE but used, then without him, so I can't transfer an ebook on my ereader.  How do I go back and allow my computer with my ID, so I can transfer my ebook on my ereader?

    Windows:

    Close all applications.

    Click Start > run.

    Open, type regedit in the text box and press ENTER. The Registry Editor opens.

    In the left pane of the registry editor, locate the following registry key: HKEY_CURRENT_USER\Software\Adobe\Adept

    Select the key of the follower.

    Choose file > export.

    In the export registry file dialog box, select the branch selected under export range. Enter a name and location for the backup registry key, and then click Save.

    Right click on the key to the follower, and then choose Remove.

    In the dialog box confirm the key deletion, click OK.

    Close the registry editor.

    Open Adobe Digital Editions and reauthorize.

    Macintosh:

    exit the Adobe Digital Editions software.

    Navigate to / Users / / Library/Application Support/Adobe/Digital Editions and drag the activation.dat file to the trash.

    If you use 10.7, see https://helpx.adobe.com/x-productkb/global/access-hidden-user-library-files.html

    Open Adobe Digital Editions and reauthorize.

    If you download eBooks before you allow eBooks can read only on this system. If you move it to a drive you need a new download after authoirze and then bound with your right ID from Adobe.

  • Problems downloading new CSS file to the title track, known for 3.1.2 bug. ?

    Hello

    I'm under APEX 3.1.2. and met some problems on download of CSS.

    I had a CSS file for an application running.
    This file I deleted and use the Create button in the shared components > Cascading Style Sheets > create a cascading stylesheet to upload the new CSS file under the same name.
    Later I tried to use some of the newly introduced classes, but they did not come to work when I run the page.

    Everything worked fine when I download the new file under a different name.
    So, it seems that the changes in the document had no effect.
    When I edited the file online new classes did not work also.

    I tried to find out by searching the weather forum and the release of notes it is a bug known to this version or not.
    Anyone of you knows?
    If it's a known bug, it is resolved to a later version?

    Best regards, Tine.

    From what you described, this could just be a problem with your browser, the CSS implementation in cache and not to pick up the update.

  • Our clients have trouble downloading a text file (.txt) on our website version 33.0 (using a filestream);

    Our clients have trouble downloading a text file (.txt) on our site version 33.0 (using a filestream). It worked well in previous versions.

    The error message they get reads as follows:
    {name of file and download user path} not can be saved, because the source file could not be read.

    Thank you
    Mike

    It is an old relative to corrupted downloads (http://kb.mozillazine.org/Source_file_could_not_be_read) error message, but has become more widespread in Firefox 33.

    To make a long story short... before, if the server sent a response which was smaller than the specified size, the gap has been ignored and the download was considered to be very good. From Firefox 33, a file that is smaller than the specified size is considered as being damaged.

    This comment in the bug tracking system has more information: https://bugzilla.mozilla.org/show_bug.cgi?id=1083090#c8

  • PC crashes with DBO when downloading a file using Firefox to my iPad

    PC crashes with DBO when downloading a large file via WiFi to my iPad and using AVPlayerHD player on the iPad. There is no report of error in Firefox, just the crash dump Windows 7 due to the accident. Only the combination of Firefox on PC and player AVPlayerHD on iPad causes this crash. Any other combination of PC and iPad works.
    Examples:
    Firefox on PC and iFile on iPad works well.
    Google Chrome on PC works with all programs on iPad.
    Firefoc on PC and player AVPlayerHD on iPad crashes.

    So you get a Blue Screen of Death on your Windows Machine? You have the exact error codes that appear when you get this blue screen?

    Blue screens mean that you have a problem with a driver, hardware or virus on your PC, not with Firefox. I try to launch a program of analysis such as http://www.resplendence.com/whocrashedand see if she can tell you what triggered the accident. Also, make sure that all your drivers are up to date on your computer (especially the graphics driver: update your drivers graphics to use hardware acceleration and WebGL) and check the virus (Troubleshooting Firefox problems caused by malware).

    After that, if you still get the blue screen and crashed does not help, I would say to try to test your RAM with a utility such as http://www.memtest.org/

  • I wrote the software for 33 years. I have a lot of apps. I would use html/xml to replace my aging FDI. Firefox is no longer execuate a binary file called directly to Hypertext on the local system. Why?

    I would rather not re - write the old of the IDE I have used for years but rather replace them with the style sheets for xml/html/web. Konqueror is running locally the binary with a launcher script. Firefox, Chrome, re-Konq, WebPositive and IE Explorer will not. If Firefox or SeaMonkey should run my binary that I could easily replace the old of the IDE and myself and my customers save a lot of time and money.

    Firefox does not execute binary files for security reasons. In other words, to prevent novice users to install malicious software.

Maybe you are looking for

  • Error message in Windows Movie Maker 2

    I use Windows XP and have the latest Service Pack. In any case, when I download a Youtube video and import it into Movie Maker, it works perfectly. Then I add the clips in the Timeline. I cut the sound. I then cut part of the video. Then when I try t

  • WRT610N v2 does NOT save new TASK force after restart

    WRT610N v2 Firmware version: 2.00.00 B05 Storage, Administration tab tab Working Group changed name of default WORKING group at HOME. After turning off the router and turning it under tension. the workgroup name is returned to the default WORKGROUP.

  • error "insufficient privileges".

    I get an "insufficient privileges" error when you run the Java stored procedure in another schema, see details below.  I don't know what are missing privileges (I already granted the EXECUTE privilege), suggestions?Define a simple java class and depl

  • Premiere Pro CC 14 &gt; no smoking or open projects

    Hi-Here's my situation.  My HD crashed into my iMac last week and he was replaced by Apple.  I reinstalled now all my apps.  Well, everything seems to work except the first.  I can open the first, open a project and it loads fine.  If I try to leave

  • A column of style in an IRR

    Hello I want a style column in an interactive report (I want the black right full of 4px border) For the column header, it works with .apexir_WORKSHEET_DATA e #column_name HO to apply it to the data in the column? Version 4.2.1 of the apex