Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Maximum number of listening ports

From: lmeyer:bltech:za at: 25-Feb-2010 9:03

Thanks for the feedback up to now. I have know included an if statement to close the port if the COPY of the port (connstatus) returns NONE (thanks Gabrielle). I also included an if statement to insert the inputmulticast to the port if the COPY of the port (connstatus) does not equal NONE. Great, it works and ports are being closed now + memory no longer increases as ports are removed from the list, but I have picked up an issue. If the remote client hogs the port (in my case the telnet session to tcp port crashed), no other connections are possible from other tcp clients until that problem connection is closed. Then only can the rest of the connections connect to the tcp server again. In the code below, I think I should have rather used "continue" in the if connstatus equals NONE block, instead of the next "if connstatus not equals NONE". But when I use "continue" I get an error that says it has no value. break works, but I believe that would result in the remainder of the ports in the ports list would not be forwarded the data for that loop cycle. Any feedback on the "One problem port stops all" issue perhaps? Code: REBOL [ Title: "4553"] mon-address: read make url! join "dns://" (read dns://) inputmulticast: open/direct/binary udp://:6553 set-modes inputmulticast [multicast-groups: copy compose/deep[[ (mon-address)]] ] listen: open/direct/binary/no-wait tcp://:4553 output-ports: copy [] forever [ port: wait [listen inputmulticast] case [port = listen [append output-ports first listen] 'else [data: copy inputmulticast foreach port output-ports [ connstatus: copy port if none? connstatus [ close port remove find output-ports port ] if connstatus <> none [insert port data] ] ] ] ]