I want to create a server that receives files (or any data) of unknown sizes
through a port. How do I know when the EOF is reached or if the other end
has closed the port?
*** server side ***
port: open/binary tcp://:2000
buffer-size: 1024
buffer: make string! buffer-size
forever [
io-port: first port
wait io-port
while [ ??? not EOF or port closed ??? ] [
read-io io-port buffer buffer-size
;*** more code goes here
clear buffer
]
clear buffer
close io-port
]
*** client side ***
host-port: open/binary tcp://127.0.0.1:2000
send-data: read/binary %anyfile.tst
insert host-port send-data
close host-port
Thanks for any help,
Max