Here is your example with some minor changes, that should work.
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"]
print copy connection
print [tab "Send answer to c-side"]
insert connection "r-side"
print [tab "Closing socket"]
close connection
]
]
rebol []
connection: open/no-wait tcp://localhost:12345
insert connection "r-side-client"
while [data: copy connection] [probe data]
close connection
halt
Robert M. Münch wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA384
>
> Hi, to track down my problem with the communication between my DLL and Rebo=
> l via sockets I tried to create a Rebol only example. Looks like it has the=
> same problem. Here is my code (much simpler than the DLL code):
>
>
> =3D=3D=3D Server
> rebol []
>
> c-port: 12345
> listen: open join tcp://: c-port
>
> waitports: [listen]
>
> print "Listening:"
> forever [
> ; wait until something happens
> connection: wait waitports
>
> if same? connection listen [
> print [tab "Connected"]
>
> print [tab "Read message from c-side"]
> c-client: first connection
> wait c-client
> print copy c-client
>
> print [tab "Send answer to c-side"]
> insert connection "r-side"
>
> print [tab "Closing socket"]
> close connection
> ]
> ]
>
>
> =3D=3D=3D Client
> rebol []
>
> connection: open tcp://localhost:12345
>
> insert connection "r-side-client"
>
> while [data: copy connection] [prin data]
> print
>
> close connection
> halt
>
>
> =3D=3D=3D Program outputs
> - --- Server
> Listening:
> Connected
> Read message from c-side
> ** Access Error: Network timeout
> ** Where: forever
> ** Near: print copy c-client
> print [tab "Send answer to c-side"]
>
>
> - --- Client
> ** Access Error: Network timeout
> ** Where: include-script
> ** Near: data: copy connection
>
>
>
> =3D=3D=3D Idea & Problem
> I want to first send a short message from client to server and than receive=
> an answer from the server side. I think I'm somehow missing either
>
> - - an "end" marker for the messages or
> - - a way to tell that the message is "complete" or=20
> - - a way to specify how long the message will be
>
> I'm sure the fix is quite simple but... I don't get it :-). Any feedback is=
> welcome. Robert
>
>
>
>
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP Desktop 9.9.1 (Build 287)
> Charset: iso-8859-15
>
> wsBVAwUBSaEFDnSQa/BbHGLwAQlSsAf/Uya52MvcoV7+I6X/n79ToKBb8CtMGUOv
> jwSO11P4+cYrKAY+3rjJtQgSUlrz4newJCzZOsysojQlO4LowUSw4sXgmeR4C8VV
> Dr74N/WFf0Bo40B+80tLpJTkNaTccm8Okf+USVFUIFBkpqJUWTlLf3pN5GAjgIWj
> vBwJqNkC6NFhVGBr95lCdjRZjhKj3LWVcQPTQvPIooZUPDt2sIiFRf6OApVYnsQr
> GcUhLZoRbadw3ss49r9kY1fIcyJ6iUU0SZ9/9Fmtoaezxk4kqMNgDPxzBufhdLd9
> 2gLBV6coxhrGjKIfBkKyCl2jgk4iQxspEYQ6X6/wsSBjAJT7eMjO9g=3D=3D
> =3DkX/q
> -----END PGP SIGNATURE-----
>
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.