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

Async Question

 [1/19] from: charles::wardell::dendrite::com at: 12-Nov-2004 13:17


Can someone give me an example of how to use the async-protocol.r I did not find any documentation other then the comments in the .r file. I am looking for an example like a simple echo server or something like that. Am I going down the right path? I saw ATCP as another option and I read that the aplha release of Rebol has ASYNC built in, but I don't know how to use that either. Thanks, Charlie

 [2/19] from: gchiu::compkarori::co::nz at: 13-Nov-2004 10:43


Wardell, Charles wrote.. apparently on 12-Nov-2004/13:17:51-5:00
>Can someone give me an example of how to use the async-protocol.r >I did not find any documentation other then the comments in the .r file. >
http://www.compkarori.com/vanilla/display/async-tutorial -- Graham Chiu http://www.compkarori.com/cerebrus http://www.compkarori.com/rebolml

 [3/19] from: antonr:lexicon at: 14-Nov-2004 1:45


This document (composed tonight) might help you to make a decision: http://www.lexicon.net/antonr/rebol/doc/ASYNC-The-available-implementations. txt Anton.

 [4/19] from: pwawood:mango:my at: 13-Nov-2004 22:55


Anton Thanks for the neat summary. Is there a "to" missing between was and provide in the following sentence ? The reason Rebol Technologies finally added this was provide a standard async root-protocol. Regards Peter On Saturday, Nov 13, 2004, at 22:45 Asia/Kuala_Lumpur, Anton Rolls wrote:

 [5/19] from: charles:wardell:dendrite at: 13-Nov-2004 11:03


I have been playing with Both the async-protocol and the atcp-protocol with no real success. I will post the atcp snippet in the next email. When using the async-protocol, it seems like the event handler never kicks off but the listen/awake function kicks seems to accept at least 1 connection because it prints "connection" Any suggestions? Rebol [ Title: none ] do %/d/projects/rebol/async-protocol.r either error? try [listen: open/no-wait tcp://:8000] [ port: open async://localhost:8000 port/awake: do handler ] [ listen/awake: func [l /local p] [ print "connection" p: first listen remove find system/ports/wait-list listen port: make port! [scheme: 'async sub-port: p] open port port/awake: do handler false ] insert tail system/ports/wait-list listen port: none ] handler: [use [ buffer ] [ buffer: copy [] func [port [port!] state [word! error!] /local tmp cmd] [ if error? :state [print mold disarm state return true] switch state [ connect [print "connected event"] read [ append buffer copy port while [tmp: find buffer newline] [ cmd: copy/part buffer tmp remove/part buffer next tmp print cmd ] false ] write [false] close [print "Connection Closed. " close port true] ] ] ] ] forever [wait []]

 [6/19] from: charles::wardell::dendrite::com at: 13-Nov-2004 11:05


In this case, It seems like I get the "dns success" message but that's about it. How should I be accessing this through the client. I am simply opening up a rebol session and trying. Testport: open/lines tcp://localhost:9000 Insert a "Hello World" I have also tried Do %atcp-protocol.r Testport: open/lines atcp://localhost:9000 Insert a "Hello World" Thanks Charlie port: open/lines/custom atcp://localhost:9000 [ awake [ foreach event port/locals/events [ either error? event [ close port ;close the atcp port return true ;stop wait ][ switch/default event [ dns-failure [ close port ;close the atcp port print "Cannot resolve the server name" return true ;stop wait ] dns [ print ["dns success:" port/host "=" port/sub-port/port-id] ] max-retry [ close port ;close the atcp port print "Can't connect to server" return true ;stop wait ] connect [ print "Ok, connected" insert port "Hello world!" ] read [ print ["Data read:" copy port] ] write [ print "All data has been written" ] close [ print "Peer closed the connection." close port ;close the atcp port return true ;stop wait ] ][ print "Unexpected event - should not happen" close port return true ;stop wait ] ] ] false ;continue wait ] ] wait-start port wait-list? forever [ wait [] ]

 [7/19] from: antonr::lexicon::net at: 14-Nov-2004 19:58

Re: Async Question - spelling


Yep, fixed, thanks. -Anton

 [8/19] from: rotenca:telvia:it at: 14-Nov-2004 12:50

Re: Async Question


You must set a server on the 9000 port to test it. --- Ciao Romano

 [9/19] from: gabriele:colellachiara at: 14-Nov-2004 13:45


Hi Charles, On Saturday, November 13, 2004, 5:03:25 PM, you wrote: WC> Any suggestions? To me it looks like you should put the assignment of HANDLER before the EITHER. Also, you are not inserting anything into the port, so that script would just do nothing. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [10/19] from: antonr::lexicon::net at: 15-Nov-2004 1:45


Hi Charles, This script has a bit of a bizarre style to it. It looks like you are using the error handling to decide whether to open a client or server. (If there's an error opening the server a second time, then become a client). So you must run the script, press escape, then run again to open the client. This is hard to understand and I don't recommend it. Better to separate the script into two clearly defined parts: server and client. It looks like you are also setting the server and client to use the same handler code. (I know, not the same instance of the handler, but still the same code.) So client and server are each waiting for the other to write something, so nothing happens ! :) On 'connect, client should send a request to the server, server will 'read this, then 'write back to the client, and the client will 'read that. Anton.

 [11/19] from: antonr:lexicon at: 15-Nov-2004 14:21


Hi Charles, Sorry about my previous, rather negative, reply. I see you were working on example code which wasn't really geared to your situation. Here is a working client/server demo: http://www.lexicon.net/antonr/rebol/async/old/demo-async-protocol-client-ser ver.r The server handles multiple clients. Just DO the above script, using Rebol/View <= 1.2.48 Regards, Anton. (ps. I'm still figuring this stuff out myself.)

 [12/19] from: charles::wardell::dendrite::com at: 15-Nov-2004 0:10


Thanks Anton; All of the code that I had in my prior emails were taken from the tutorials. The ATCP doc and the ASYNC Tutorial. I did try running the file through view for the link you provided and I get. ** Script Error: attempt has no value ** Where: send-to-server ** Near: attempt [port/host: to-tuple port/host ]
>>
I am having a hard time getting any of the examples to work so I downloaded the latest view and still no luck. Thanks, Charlie

 [13/19] from: SunandaDH::aol::com at: 15-Nov-2004 4:43


Charles:
> ** Script Error: attempt has no value
The REBOL development environment is a mess of overlapping and incomplete versions of the REBOL.exe. And it is not always clear when someone posts some code whether you need to download yet another REBOL.exe to get that code to work. I suspect you have the official REBOL/View download from http://www.rebol.com/download.html (The official REBOL/Core includes 'attempt, but the official REBOL/View does not) You could try a beta from.... http://www.rebol.net/builds/ ....provided there is an appropriate beta for your platform. .....but be careful not to overwrite your existing REBOL.exe as the newer beta may break some code in existing applications. Or you could define 'attempt as a function -- this is taken from a recent beta:
>> source attempt
attempt: func [ {Tries to evaluate and returns result or NONE on error.} value][ if not error? set/any 'value try :value [get/any 'value]] That gets you past the 'attempt, but you may fail later if the code you are executing requires other beta features. Good luck! Sunanda

 [14/19] from: antonr::lexicon::net at: 16-Nov-2004 0:21


Hi Charlie, I am mainly testing with Rebol/View 1.2.48.3.1 This version is the last version that works with the ASYNC:// protocol. Get it from here: http://www.rebol.net/builds/ Sorry for not mentioning it. I'm just so used to it I forget other people might not be using it. :) Anton.

 [15/19] from: charles::wardell::dendrite::com at: 16-Nov-2004 2:07


Thank you again. You were right. I downloaded the alpha and things start working. Thanks for all your help. Charlie

 [16/19] from: charles:wardell:dendrite at: 16-Nov-2004 12:49


Anton, Thank you for the example code. I see that it is working so I do not have any real issues. I did separate the code into client and server pieces and was just wondering why I would be receiving:

 [17/19] from: charles::wardell::dendrite::com at: 16-Nov-2004 12:51


Anton, Thank you for the example code. I see that it is working so I do not have any real issues. I did separate the code into client and server pieces and was just wondering why I would be receiving: the invalid argument: async-modes? Client state: connect Client: connected to server Client: sending message... the-message: "Howdy" Client: Message sent. ** Script Error: Invalid argument: async-modes ** Near: sset-modes port [async-modes: none] if port/scheme
>> Client state: write
If you could shed some light on this, that would be great..

 [18/19] from: antonr::lexicon::net at: 18-Nov-2004 0:26


Hi Charles, I know it's confusing, but to get that error you must be now using a version of Rebol/View which is *too* recent. You must use Rebol/View version 1.2.48 (or less), because this is the last version which uses the old async core (and thus, supports the ASYNC:// protocol). You can actually gather this from the document I wrote, but, I understand, it's a bit of a confusing situation at the moment. :) I'll post you directly with the precise binary you need, since rebol.net seems to be down at this time. Regards, Anton.

 [19/19] from: charles:wardell:dendrite at: 17-Nov-2004 10:26


What happens if you need Async Functionality with CMD features like DLL/ODBC?