Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Might as well ask..

 [1/11] from: andy:flyingcat at: 3-Oct-2002 14:19


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

 [2/11] from: gscottjones:mchsi at: 3-Oct-2002 14:38


Hi, Andy, From: "Andy Finkel"
> 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 :-)
I clearly am suffering from flatulence of the brain. After sending my last submission stemming from Petr, I recalled doing something with Petr *last* year along these lines, that time using *skip* but on a http network connection. Here was the snippet (still works): from-port: open/direct http://www.microsoft.com to-port: open/direct %//windows/desktop/log.txt from-port: skip from-port 8000 ;skip first 8000 bytes ;get 1000 byte chunks from file while [data: copy/part from-port 1000][append to-port data] close from-port close to-port Here was the email: http://www.escribe.com/internet/rebol/m10053.html
> Has anyone done a tcp binary file transfer in rebol ? > (one system sends, the other receives, both using the
<<quoted lines omitted: 3>>
> be able to more easily play around with different protocols > if it were all in Rebol.
Shouldn't be too hard (he says with a great deal of bravado), but I have not had the need to do this, per se. If the previously mentioned solutions don't serve your needs (like you *really* need tcp, and want to avoid http) and no one offers a solution, I could probably whip one up. I'm out of time right now, but if no sno answers come forward, I'll check into it later today. --Scott Jones

 [3/11] from: rebol:compkarori at: 3-Oct-2002 15:47


-- Unable to decode HTML file!! --

 [4/11] from: andy:flyingcat at: 3-Oct-2002 16:33


Hi: Well, without the skip (which I was using to resend part of the file) , the code (which does work) looks like: --------------------- rebol [ "TCP File Client" ] port: open/binary/direct tcp://localhost:5242 outfile: open/binary/direct/write/new %qwe.vts forever [ data: copy/part port 32768 if (none? data) [break] insert outfile data ] print ["file received"] close outfile close port ---------------------------- rebol ["TCP File Server" ] listen: open/binary/direct tcp://:5242 forever [ connection: first listen file: open/binary/read/direct %/usr/video/qwe.vts forever [ data: copy/part file 32768 if( none? data ) [ break ] insert connection data ] print ["file sent"] close connection close file ] close listen ----------------------- 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 ? Andy

 [5/11] 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 :-)
<<quoted lines omitted: 5>>
>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-

 [6/11] from: gscottjones:mchsi at: 3-Oct-2002 18:08


Whoops. Forgot to close the server socket and take out some debugging print statements. --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 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 connection: first listen wait connection 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"] close connection close file ] close listen

 [7/11] from: gscottjones:mchsi at: 3-Oct-2002 18:03


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

 [8/11] from: rebol::compkarori::com at: 3-Oct-2002 18:36


Just testing to see what's wrong<BR><BR>--<BR>Graham Chiu<BR><BR><BR> <BLOCKQUOTE dir=ltr style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style="FONT: 10pt arial">--------- Original message --------<BR>From: Andy Finkel <[andy--flyingcat--com]><BR>To: "[rebol-list--rebol--com]" <[rebol-list--rebol--com]><BR>Subject: [REBOL] Re: Might as well ask..<BR>Date: 10-03-02 20:29<BR><BR><FONT face="Courier New" size=2>Hi:<BR><BR>Well, without the skip (which I was using to resend part of the file) ,<BR>the code (which does work) looks like:<BR><BR>---------------------<BR><BR>rebol [ "TCP File Client" ]<BR><BR>port: open/binary/direct tcp://localhost:5242<BR><BR>outfile: open/binary/direct/write/new %qwe.vts<BR>forever [<BR>data: copy/part port 32768<BR>if (none? data) [break]<BR>insert outfile data <BR>]<BR>print ["file received"]<BR>close outfile<BR>close port<BR><BR>----------------------------<BR><BR>rebol ["TCP File Server" ]<BR><BR><BR>listen: open/binary/direct tcp://:5242<BR><BR><BR>forever [<BR>connection: first listen<BR>file: open/binary/read/direct %/usr/video/qwe.vts<BR>forever [<BR>data: copy/part file 32768<BR>if( none? data ) [ break ]<BR>insert connection data<BR>]<BR>print ["file sent"]<BR>close connection<BR>close file<BR>]<BR>close listen<BR><BR><BR>-----------------------<BR><BR><BR>The one thing I haven't convinced Rebol to do is let me read a parameter<BR>(the filename) from the listen port on the server side before sending<BR>the file. Any ideas ?<BR><BR><BR>Andy<BR><BR><BR><BR><BR><BR>-- <BR>To unsubscribe from this list, please send an email to<BR><A class=autolink href="mailto:[rebol-request--rebol--com]">[rebol-request--rebol--com]</A> with unsubscribe in the <BR>subject, without the quotes.<BR><BR><BR></FONT></DIV></BLOCKQUOTE>

 [9/11] from: gscottjones:mchsi at: 3-Oct-2002 18:55


In case it looks funny, my last two e-mails in this thread swapped places in the queue! :-) --Scott Jones

 [10/11] from: gchiu:compkarori at: 4-Oct-2002 13:06


I once asked Maarten whether Rugby could be used for binary file transfers ... I don't remember the answer he gave me now ! Perhaps he could chip in if he finds the time. -- Graham Chiu

 [11/11] from: g:santilli:tiscalinet:it at: 4-Oct-2002 11:39


Hi Andy, On Thursday, October 3, 2002, 8:19:57 PM, you wrote: AF> Has anyone done a tcp binary file transfer in rebol ? (one system AF> sends, the other receives, both using the direct tcp: ports). FTP won't Yes, in many ways. I also wrote, a lot of time ago, a "simple file transfer protocol", that was never released because I never finished it. It basically allowed to open a file port on a remote computer, and then control that port as if it were local. So, from REBOL, you had access to the remote file system as if it were local... AF> do it, as I need to process the file in 32K chunks (and I'd like to If it wasn't for the bug in SKIP on file ports, I think it would be trivial to write. (You just COPY/PART from the source file port and INSERT into the tcp port; on the other side you COPY/PART from the tcp port and INSERT into the file port.) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted