Home   Archive   Permalink

wait reduce [listen 0]

I am reading webserv.r of Cal Dixon, Would someone like to explain the code line show below:
if none? wait reduce [ listen 0 ] [ return ]
What confused me is wait reduce [listen 0]!

posted by:   limux       17-May-2011/12:22:57-7:00

I have read the port chapter of the rebol core guide, and know that "wait [listen 0]" is to wait listen with 0 of timeout, but I don't know why use reduce? The "wait [listen 0]" worked same as with reduce exactly, Is my understanding right?

posted by:   limux       18-May-2011/11:11:47-7:00

The interpretation depends on the value of the LISTEN word. It is likely that it holds the network port that the web server is listening on. LISTEN as an unreduced symbol does not specify any port, so it doesn't work that way. WAIT can then only wait until the timeout, which is immediately, so it becomes a useless operation.

posted by:   Kaj       18-May-2011/14:46:39-7:00

Would you like to give a simaple example?

posted by:   limux       19-May-2011/6:26:11-7:00

Well, you have a simple example right there. How could it be made simpler?

posted by:   Kaj       19-May-2011/12:00:26-7:00

    listen: open udp://:2552
     wait reduce [listen 10]
     copy listen
     type? first [listen 10] ; >> word!
     type? first reduce [listen 10] ; >> port!
But actually wait already take care about it.
     wait [listen 10] ;this also works
May be older versions of Rebol act different.

posted by:   Endo       23-May-2011/7:21:34-7:00