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

[REBOL] Port probing Re:(3)

From: jschuhr:hot:mail at: 17-Oct-2000 12:11

How does the "view" function handle calls to other functions? I have the following scenario: testserver.r +------------------------------------ REBOL [ title "Test Server" ] system/console/busy: none start-server: func [] [ server-port: open tcp://:8001 forever [ connection-port: first server-port wait connection-port data-recvd: copy connection-port if data-recvd <> none [ print data-recvd ] close connection-port clear data-recvd wait 00:00:01 ] ] view layout [ button "Startup" [start-server] button "Shutdown" [quit] size 200x200 ] +--------EOF--------------------------- testclient.r +-------------------------------------- REBOL [] send-message: :save view layout [ button "Send message" [ send-message tcp://localhost:8001 "Message test" ] button "Exit" [quit] ] +----------EOF------------------------- The testserver.r starts and the window shows up. The user clicks on "Start server" and the server starts listening for messages. The testclient.r starts up and the user and send test messages by clicking on the button and as expected, the server displays the messages. However, at this point, REBOL/View isn't interactive anymore for the testserver.r reblet. How does blocking on a port affect View and how can one listen on a port and maintain interactivity in the window? --John
>From: [ptretter--charter--net] >Reply-To: [list--rebol--com] >To: [list--rebol--com] >CC: <[holger--rebol--com]> >Subject: [REBOL] Port probing Re:(2) >Date: Tue, 17 Oct 2000 10:55:23 -0500 > >I tried play with this with this script while opening another console and >inserting to those ports. I got no expected output. The core docs need >to >be updated to explain listening on more than one port. > >REBOL[] >port1: open tcp://:55 >port2: open tcp://:56 > >while [true][ >wait [port1 port2 0] >buffer1: first port1 >buffer2: first port2 >print buffer1 >print buffer2 >] > >-----Original Message----- >From: [holger--rebol--com] [mailto:[holger--rebol--com]] >Sent: Monday, October 16, 2000 10:42 PM >To: [list--rebol--com] >Subject: [REBOL] Port probing Re: > >On Mon, Oct 16, 2000 at 10:12:13PM -0500, [ptretter--charter--net] wrote: > > If I have to ports that I wait for data on how can I put them in a while >or > > forever loop without locking up the console. If I had a if statement > > testing data received. > >That depends on the type of port and the version of REBOL you use. Assuming >tcp, udp or serial ports opened with /direct, you can wait for multiple >ports >with > >wait [port1 port2] > >which returns one of the ports if it has data, none otherwise. To get a >block >of all ports returned instead of just a single port use wait/all (latest >experimental version only). > >To just poll ports without blocking add a timeout of zero, i.e. try > >wait [port1 port2 0] > >Using a timeout of zero to poll only works with some old (pre-2.3) versions >of REBOL (on some platforms) and with the latest experimental versions (on >all >platforms), but not with REBOL 2.3. > >Other types of ports currently do not support 'wait. Higher-level network >ports (HTTP etc.) will probably support it in one of the next experimental >versions, when opened with /direct. > >You may also want to look at the no-wait refinement for 'open. It >guarantees that 'copy on a port never blocks, even if there is no data >available on it (latest experimental version only). > >-- >Holger Kruse >[holger--rebol--com] >
_________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com.