Hi, Andy,

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
making sense.

Interesting project!

--Scott Jones

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?"
][
    wait port
    response: first port
    print response
    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"]
        close outfile
    ][
        print "Hmmm - We've got a problem, Houston."
    ]
]
close port

----------------------------

rebol ["TCP File Server" ]

listen: open/lines/direct/no-wait tcp://:5242

forever [
    connection: first listen
    wait connection
    either error? try [
        fname: first connection
        print fname
    ][
        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"]
        close connection
        close file
    ]
]
close listen


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to