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

[REBOL] Re: No-wait

From: petr:krenzelok:trz:cz at: 23-Feb-2004 15:19

Paul Tretter napsal(a):
>Yeah this was my current work around to use 0 as a timeout but I was a >wondering why it was needed if there was no-wait. >
It was not imo. Your code was imo wrong for what you wanted to achieve: port: open/direct/no-wait tcp://:7000 x: 0 forever [ print x + 1 x: x + 1 data: first wait port ] Do you know what above code is basically doing? You opened so called listen socket - TCP "channel" assigned to you by OS. That kind of socket is able to accept new connections, nothing more. One there is new client asking for connection, it simply assigns it other type of socket, so called communication socket. Just look at 'probe of given port and look for 'local-port item - that is the port assigned to you by OS. So basically - what did you expect your above code will do? I think I can tell you :-) Your 'forever loop will hang on, untill there is new connection coming. Just open second console and type-in: client: open tcp:// and your 'x will counter will be raised by 1 - You created nothing more, than connection counter. For that, you choosed wrong name 'data. I would suggest: console1: --------- server: open/direct/no-wait tcp://:7000 conn: first wait server forever [ wait conn data: copy conn print mold data ] console2: --------- client: open tcp:// data: read %user.r forever [ insert client data wait 5 ] Just copy and paste and watch your simple client/server communication ..... you can put your console code in another loop, which will be able to accept several connection, wait on list of clients connected and voila, - you've got your tcp multiplexing engine running. Wouldn't above short description/example make it for short beginner's tutorial? :-) ... except the fact, that I am beginner too :-) Cheers, -pekr-