[REBOL] Re: Might as well ask..
From: petr:krenzelok:trz:cz at: 3-Oct-2002 22:30
Andy Finkel wrote:
>Since the skip bug was known to the list, perhaps someone on the list
>has done the entire problem , so I might as well ask :-)
>
>Has anyone done a tcp binary file transfer in rebol ? (one system
>sends, the other receives, both using the direct tcp: ports). FTP won't
>do it, as I need to process the file in 32K chunks (and I'd like to
>avoid the overhead of the ftp server). It's simple enough in C, but I
>thought I'd be able to more easily play around with different protocols
>if it were all in Rebol.
>
>Andy
>
Well - in rebol, it is simple. There are just some bugs or missbehaviors
as that of open/direct etc. Also - with our device, we were screwed up,
-imo a Rebol bug - simply 'waiting on port didn't work, unless we added
/binary refinement. I was told by Carl on IOS that we should use /binary
for such transfers, but imo 'wait should wait and it should behave the
same no matter what refinement combination we use ....
So - I like async, not blocking port behavior, that's why I open my
ports in direct and no-wait mode. Simple simulation you can play with:
client:
------
REBOL []
client: open/direct/no-wait tcp://your-ip:9005
while [wait client data: copy client][print data]
close client
server:
-------
REBOL []
server: open tcp://:9005
conn: first wait server
file: read %some-file.txt
for i 1 100 1 [
insert conn file
wait 1
]
close conn
close server
I just wanted to test, that client properly waits 1 sec, then reads
data, prints it, etc.
That's just simple client/server communication. As for file transfer, I
would use /binary refinement too, would read source in parts, send it
in, and append it to the file on the other end. I did some download-it!
script for http downloads, as I was tired of browsers inability to
continue broken downloads ... If you will be interested, I can send it
to you or help you otherwise ...
-pekr-