** Script Error: Cannot use copy on this type port
[1/2] from: rchristiansen::pop::isdfa::sei-it::com at: 18-Dec-2000 18:28
I'm teaching myself how to write to and read from ports in REBOL.
While trying to copy the data from a port, I get the following error:
** Script Error: Cannot use copy on this type port
Can anyone tell me why I cannot use 'copy? I get this error when I
use the tcp protocol and the open/lines or open/string refinement. I
do not get this error when I use the udp protocol.
Here is an example of client and server scripts that do work (if I
change the first line of each script to open/lines tcp:* or to
open/string tcp:* I get the error):
REBOL []
client: open udp://localhost:8009
forever [
message: input
insert client message
wait client
print copy client
]
REBOL []
server: open udp://:8009
forever [
wait server
receipt: copy []
receipt: copy server
print receipt
insert server "ACK_RESPONSE"
]
[2/2] from: jkinraid:clear at: 21-Dec-2000 17:10
Ryan C. Christiansen
wrote:
> I'm teaching myself how to write to and read from ports in REBOL.
> While trying to copy the data from a port, I get the following error:
>
> ** Script Error: Cannot use copy on this type port
>
> Can anyone tell me why I cannot use 'copy? I get this error when I
> use the tcp protocol and the open/lines or open/string refinement. I
> do not get this error when I use the udp protocol.
tcp is different from udp in this respect, a server using tcp creates a
seperate connection for each client that connects to the server. So
after doing a wait on a server, you have to get the connection. You can
do this using 'first, "new-connection: first wait server". Then you can
copy from new-connection.
server: open tcp://:8009
forever [
new-connection: first wait server
receipt: copy new-connection
print receipt
insert new-connection "ACK_RESPONSE"
close new-connection
]
Note that there are other difference between tcp and udp, so that
previous example probably won't work as you'd expect. There are some
more examples in the core pdf, under Network Protocols->TCP.
> Here is an example of client and server scripts that do work (if I
> change the first line of each script to open/lines tcp:* or to
<<quoted lines omitted: 16>>
> insert server "ACK_RESPONSE"
> ]
Julian Kinraid
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted