[REBOL] tcp ports and buffer size? Holger?
From: petr:krenzelok:trz:cz at: 30-Aug-2001 12:27
Hello,
today I needed to increase number of our downloadable mainframe files.
This time - first ones from SAP R3. Not much of a problem, unix-like ftp
we don't have access too, so I have to wrap company website using post
method to get files.
However, download of two of my files ended with 4096 bytes of downloaded
data. I wondered why and found out some strange behavior I don't
understand. I have following code:
http-port: open [
scheme: 'tcp
port-id: port-spec/port-id
timeout: port-spec/timeout
host: port-spec/host
user: port-spec/user
pass: port-spec/pass
]
;inserts 'post request
insert http-port http-request
;uncomment the next line if you wish to skip some amount of info
;http-port: skip http-port 2000
view/new layout [
styles styly
vh2 gold "Stahuji soubor, čekejte prosím ..."
across
lab "Staženo: " p: text 80 bold right white "0" return
lab "Čas:" t: text 80 bold right white "0"
]
l: 0
start: now/time
while [data: copy/part http-port buffer-size][
print mold data
append target-port data
l: l + (length? data)
p/text: to-string l
t/text: to-string now/time - start
show p show t
]
print type? data
close http-port
close target-port
So, basically, I used pure 'open - no other refinement. No matter if I
used pure while [data: copy http-port], I always ended with file of 4096
bytes size. I even tried to use "wait http-port" inside of 'while block,
but no success - "print type? data" following the loop always reported
'none. I also tried to use /no-wait refinement, but still the same.
I have buffer-size defined 20000. Now I lovered buffer size to be less
than those mystery 4096 bytes, to 2000, and my file was downloaded
correctly. So, what am I doing wrong?
- why 'copy doesn't block if I don't use /no-wait refinement?
- why using /no-wait and while [data: copy http-port] copies those 4096
bytes, then leaves loop, reporting data being none!, while it should be
an empty string instead? (waiting for port doesn't help here, loop is
left anyway ...)
My temporal solution is to use low enough buffer size and copy/part
http-port buf-size ....
Thanks a lot,
-pekr-