ok, the same example
with waiting for events and ping pong messages in a 10 sec forever
intervall.
This you can do with many sockets too, but then it is more elegant to
use awake finctions.
rebol []
c-port: 12345
listen: open/no-wait join tcp://: c-port
waitports: [listen]
print "Listening:"
forever [
; wait until something happens
either same? listen connection: wait waitports [
print [tab "Connected"]
c-client: first connection
append waitports c-client
] [
print [tab "Read message from c-side"]
msg: copy connection
either not msg [
print [tab "Closing socket"]
close connection
] [
print msg
print [tab "Send answer to c-side"]
insert connection "r-side"
]
]
]
rebol []
connection: open/no-wait tcp://localhost:12345
forever [
insert connection "r-side-client"
wait connection
probe copy connection
wait 10
]
Robert M. Münch wrote:
> Am 23.02.2009, 11:31 Uhr, schrieb sqlab <[email protected]>:
>
>
>> Here is your example with some minor changes, that should work.
>>
>
> Hi, some more questions:
>
> 1. The client now uses active polling. Is there a way to let it WAIT until
> something is there?
>
> 2. How to send messages back and forth in a loop without closing the
> socket?
>
> 3. This here is one round-trip that only works if the socket is closed.
> Not closing the socket won't send the answer to the client. Instead the
> client loops forever.
>
>
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.