[REBOL] Re: UDP Multicast to TCP
From: petr:krenzelok:seznam:cz at: 18-Nov-2009 11:42
Hi,
I hope I am not wrong here, but you should know, that in R2, you
basically can work in two modes - blocking (synchronous), and non
blocking. When you open your port without /no-wait refinement, then
'copy action on port blocks. It is your case, as you issue "copy
multicast", where multicast is opened in blocking mode. In this mode,
copy waits for other side to close the connection. That might be the
reason why your code "halts". Try simple example:
Console1:
---------
server: open tcp://:9005
conn: first server ;--- here 'first blocks, waiting for connection
print copy conn ; --- here 'copy blocks, waiting for other end, to
close the connection
Console2:
client: open tcp://localhost:9005
insert client "123"
insert client "456"
;--- unless you close client, Console1 is not printing anything, it is
still being blocked ...
close client ;--- now your stuff gets printed in console1
Now try the same with server: open/no-wait tcp://:9005
The scenario changes, and you have to change your logic. You have to
wait, where possible, or you code runs out. E.g. line of "conn: first
server" will return imediatelly, so you have to change it to "conn:
first wait server" - I suggest using this logic even for blocking ports
mode, because then you save yourself a few surprises.
Also remember - in /no-wait mode, it is regular to receive empty data
buffer - there is simply no data. If you need to distinguish when port
is being closed, check for "none" value.
HTH,
-pekr-