[REBOL] Re: Might as well ask..
From: gscottjones:mchsi at: 3-Oct-2002 18:03
From: "Andy Finkel"
> Well, without the skip (which I was using to resend part of the
> file) , the code (which does work) looks like:
<original code snipped>
> The one thing I haven't convinced Rebol to do is let me read a
> parameter (the filename) from the listen port on the server side
> before sending the file. Any ideas ?
You are a whiz! I am amazed at how quickly you soak this stuff up.
I took your code as a base, but I changed a few things because I am on Win98
and needed to work with a file that I had locally (no kidding! :-). I
started the ports in lines mode, did some interacting to get the file name,
through in a smidge of error detection (but it needs lots more), discovered
an apparent bug in set-modes, and finally got it to work. Of course, this
skips the skip. Maybe it can be work mack in where necessary, but for the
sake of your prototype code, I skipped the skip. Watch the line breaks.
Make it fit your sample and let me know how it goes and/or if my code is not
rebol [ "TCP File Client" ]
port: open/lines/direct/no-wait tcp://localhost:5242
either error? try [
insert port "nyc.jpg"
print "whoopsie - where's the beef?"
response: first port
either find response "OK" [
set-modes port [binary: true]
set-modes port [lines: false]
outfile: open/binary/direct/write/new %//windows/desktop/nyc.jpg
while [data: copy/part port 32768] [
append outfile data
print ["file received"]
print "Hmmm - We've got a problem, Houston."
rebol ["TCP File Server" ]
listen: open/lines/direct/no-wait tcp://:5242
connection: first listen
either error? try [
fname: first connection
insert connection "Error - Go fish ..."
insert connection "OK - Get Ready..."
set-modes connection [binary: true]
set-modes connection [lines: false]
file: open/binary/read/direct join %//rebol/view/ fname
while [data: copy/part file 32768] [
insert connection data
print ["file sent"]