0

Using One of the cookbook examples, I am trying to make a server like so in Rebol2:

listen: open tcp://:9999
waitports: [listen]
forever [
data: wait waitports
either same? data listen [
        active-port: first listen
        append waitports active-port
][
        incoming-from-remote: first data
        print incoming-from-remote
    ]     
]

With a client I can connect and send messages by inserting them, but when I close the port from the client side, I get the following error on the server:

** Script Error: Out of range or past end
** Where: forever
** Near: incoming-from-remote: first data
print incoming-from-remote

How can I handle this better?

kealist
  • 1,669
  • 12
  • 26

1 Answers1

0

put this in your either block

either any [ 
   not incoming-from-remote: copy data
   "" = incoming-from-remote
] [
   attempt [
      close data
      remove find waitports data
   ]
] [
  print ..
]
sqlab
  • 6,412
  • 1
  • 14
  • 29