World: r3wp
[!Uniserve] Creating Uniserve processes
older newer | first last |
Will 19-Jan-2009 [603] | maybe you can get what you want with iptables or ipfw (on os x it's ipfw) |
Oldes 19-Jan-2009 [604x2] | So you think that using something like: ... uniserve/boot/no-wait forever [ wait 0:0:1 foreach-listener-write-enough-data-to-play-1s ] ... is not good approach? I think I cannot do it from 'on-write as this would require to have separate input for each listener, which I don't want. What happens is I write on port which does not finished previous write? |
Will... I want to make a private mp3 stream server to play music on a local network. So it must be solved on the server side... read only enough sound data from disk to play and distribute it to listeners. I have already the mp3 parser to get for example enough data to play during specified interval of time. Now it's just how to distribute it and don't send more data than is necessary for the listeners. | |
Dockimbel 19-Jan-2009 [606] | I don't remember if WAIT is processing network events when called with a time! value. If it's not processing events, your writes would have to be in blocking mode, so sending data one after another. |
[unknown: 5] 19-Jan-2009 [607] | I wouldn't think that wait would be working like that. I think you can only use wait [] to process the wait-list. |
Dockimbel 19-Jan-2009 [608] | UniServe would be then useless, because it couldn't work in async mode. |
Oldes 19-Jan-2009 [609x2] | it should be wait [ 0:0:1] |
I will test it anyway | |
Dockimbel 19-Jan-2009 [611] | Wait [ 0:0:1] won't work as you expect. You don't have any guaranty that it will exit from the loop every seconds. It depends on network activity. The time! value indicates a timeout duration from last network event. |
Oldes 19-Jan-2009 [612] | Which events? Even the on-write events? Not being called in precise interval would not be a problem. I think. |
Dockimbel 19-Jan-2009 [613x2] | For example, if you have, on average, one network event (port opening, packet coming, packet to be sent (async write),...) every 0.5sec, it's enough to delay the exit from your WAIT [ 0:0:1 ] for several seconds or even minutes. |
As long as you get any event happening before a timeout occurs, you'll stay in the WAIT event loop. | |
Steeve 19-Jan-2009 [615x2] | what the prob ? if you do a wait [0.001] it should process one event at a time. |
maybe wait [0] works too | |
Oldes 19-Jan-2009 [617] | Ah.. I see Doc, that is a problem.. so it looks I will have to write the data from 'on-write. Just will have to find out, how to make it synced, because I would like to have all listeners play the sound in the same moment. If it's possible. |
Dockimbel 20-Jan-2009 [618] | WAIT [0] should return just after the first event is processed, but that's not the point. It's about being able to send the same amount of data every seconds. |
Pekr 20-Jan-2009 [619x3] | how can you do it in terms of single process? |
As long as you get any event happening before a timeout occurs, you'll stay in the WAIT event loop. - Doc - is it really correct? I am far from being guru here, but it sounds strange - that would mean, that as far as there are events coming, you are not allowed to quit wait, no? I think that 'wait waits for either the event, or an timeout to occur. If there is any kind of event on port in wait-list, 'wait return. It can either return with first port with event, or, when using /all refinement, with block of all ports, which have event available on them at the time of return ... | |
but - you surely know what you are talking about, so I have to be wrong :-) | |
Dockimbel 20-Jan-2009 [622x3] | WAIT has many different behaviours depending on the passed argument. |
When called with [ ] or [ integer! ], WAIT will process all ports stored in system/ports/wait-list. In that case, WAIT will block until : - a timeout is specified and no more events are received for that timeout period - an event returns a TRUE value. | |
Not sure about the WAIT [port1 port2 ...] case. I guess that it will process all events from system/ports/wait-list but will exit on first event received by port1, port2,... | |
Oldes 20-Jan-2009 [625x3] | just tried to add this before cheyenne starts: do-events: does [ forever [wait [0:0:1] print now/time/precise] ] And from second console run: loop 1000 [read http://localhost] the result is, that it prints the time in every second while it serves the requests. |
In the same time it was serving MP3 from modified micro-http service using something like: on-received: func [data][ write-client rejoin[ {ICY 200 OK} crlf {icy-name: LocalRadio} crlf {icy-genre: whatever} crlf {icy-url: http://127.0.0.1:811} crlf {content-type: audio/mpeg} crlf {icy-pub: 1} crlf {icy-br: 128} crlf crlf ] write-client path-to-mp3-file close-client ] | |
And running my RebolBB with responses <16ms | |
Steeve 20-Jan-2009 [628] | So Doc was wrong, it's unusual... |
Dockimbel 20-Jan-2009 [629] | Oldes: thanks for taking the time to test it. The correct behaviour of WAIT is the one you've described. I'm glad you've corrected me on that one. I'm pretty sure that I've run such tests with different results when working on UniServe five years ago. Maybe something changed in REBOL kernel since then or maybe my test script was just flawed. Nice to see that there's still something to learn from R2. |
Janko 20-Jan-2009 [630] | wow, audio streaming in rebol and uniserve .. cool |
NickA 21-Jan-2009 [631x2] | I need to learn more about thay! |
thay -> that | |
Oldes 21-Jan-2009 [633] | on-write is dissabled in the recent versions. Why? |
Dockimbel 21-Jan-2009 [634] | What makes you think that? |
Oldes 21-Jan-2009 [635x2] | ; --- temporary deactivated ;on-write port |
0.9.17 21/12/2004 { o Added 'on-write-done event. o 'on-write call in 'write-peer temporaly deactivated. o bugfix in 'open-port, custom port-id now correctly used. } | |
Dockimbel 21-Jan-2009 [637x3] | Right, that was a workaround for a packet sending issue, but never had to reactivate it. |
It was useful on client side to kickstart first packet sent to a server (kind of fast shortcut to avoid a round in event loop before sending the first packet), but I had more issues than benefits from it, so I left the code deactivated in case I would need it in future, but it looks like I could remove those lines. Do you have a need for it? | |
Btw, 'on-write is not disabled in UniServe, it's just no more directly called in that specific case. | |
Oldes 21-Jan-2009 [640] | probably no.. just found it as you told me, that I should control the data from it. |
Dockimbel 21-Jan-2009 [641] | Right, controling bandwidth requires changing UniServe's internals, mostly in 'on-write handler. |
Maarten 19-Feb-2009 [642x2] | The balloon goes up! I want to move Rugby's transport layer to Uniserve, or even better, Cheyenne. (http tunneling). For this to really work I only need to know if you have primitives for timers in the event loop (inside the 'wait): do-every time! [ code ] do-after time! [code] |
The rest will be porting transport and state machines on the server, but as Rugby already had a CGI interface it hould be simle to use the server with Cheyenne. | |
Dockimbel 19-Feb-2009 [644] | That feature is waiting for weeks to be implemented (need it for adding a mail relay agent to Cheyenne and for cron-like jobs scheduling), I'll give it some time this weekend. |
Graham 19-Feb-2009 [645] | Is this convergence ? :) |
Maarten 20-Feb-2009 [646] | No, this will be world domination ;-) |
Pekr 20-Feb-2009 [647x3] | Rugby to the rescue! I always wanted general multiplexing architecture being part of REBOL natively, but then I also wanted simplicity of Rugby. Now I will get both? :-) |
Maarten - what about Chord concept, is it still valid? Or is there anything better out there worth implementing? | |
btw - what is missing in R3 to start porting of Uniserve to R3? Higher level protocols? Or tasks? | |
Dockimbel 20-Feb-2009 [650] | Stability maybe? ;-) |
Maarten 21-Feb-2009 [651x2] | First ugby on Uniserve. Then Chord on top of that.... Chord on Rugby is already working. |
Nenad, this may help you: http://www.colellachiara.com/soft/Libs/timers.r | |
older newer | first last |