[REBOL] Re: Problem: Talking from Rebol to Rebol via socket
From: robert:muench:robertmuench at: 22-Feb-2009 14:50
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA384
Hi, I made some small steps forward. At least I can send a message and get an answer.
But only once, I want this to run in a loop on the server and the client side. My actual
code now is:
=== Server
rebol []
c-port: 12345
listen: open/direct/no-wait join tcp://: c-port
waitports: [listen]
print "Listening:"
; wait until something happens
connection: wait waitports
if same? connection listen [
print [tab "Connected"]
c-client: first connection
forever [
print [tab "Read message from c-side"]
print copy c-client
print [tab "Send answer to c-side"]
insert c-client "r-side"
]
]
=== Client
rebol []
connection: open/direct/no-wait tcp://localhost:12345
forever [
print "Sending to Rebol server"
insert connection "r-side-client"
print "Receiving from Rebol server"
prin tab
while [data: copy connection] [prin data]
print newline
]
=== Problem
The client side can only send once because it get stuck in the WHILE loop always getting
some data from the server. The server loops, doesn't read anything from the client and
immediately sends out the next message to the client.
Is there a way that I can WAIT to "read a message" or "send a message"? I'm missing a
way to control/react on the communication direction flow.
- --
Robert M. M=FCnch
Management and IT freelancer
http://www.robertmuench.de
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.9.1 (Build 287)
Charset: iso-8859-15
wsBVAwUBSaFYJnSQa/BbHGLwAQnnwQf6AmlifawzCwI7bKXPXpXvGeCoac0L2DJC
VlA5+BNzwCg/OXjFkD07mN+WDV6yM2zXDWy/HzaK6IPyz3GHmdw/DVU29kp6RqE+
zcn7nRwXPx3edfRbet4lWlBoU4HrHGMsZDTPSSBf0+y1s6chSaLuzGVrnF2hsVgd
REHUhKHlUDA234CWtJaoNXLpHqdXtN+adkRXu0BuPJ92QyKDifQ7/dPU4GRBKGQ9
AQBnBfRmvlPTQZAJfWETP2xX+4uFMhx4jfxpNVKGCIrebWIdqCaq6e3OXBeRSAPS
zyr7GmJLeNQD1mxeHkOMFEReG75Hy2JsUtpU7ogfRgPj3Iqn7N9jIA==
=owqz
-----END PGP SIGNATURE-----