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

[REBOL] Re: UDP Multicast to TCP

From: santilli:gabriele:gm:ail at: 18-Nov-2009 11:12

On Wed, Nov 18, 2009 at 5:05 AM, Leon Meyer <lmeyer-bltech.co.za> wrote:
> Here is the code:
I'd do it this way:
> REBOL [ Title: "Multicast Receiver"] > > mon-address: read make url! join "dns://" (read dns://) > inputmulticast: open udp://:6554 > set-modes inputmulticast [multicast-groups: copy compose/deep [[239.2.0.81 > (mon-address)]] ]
listen: open/direct/no-wait tcp://:4554 ; copy not really needed here, ; but just in case you move this to a function for eg. output-ports: copy [] forever [ port: wait [listen inputmulticast] case [ port = listen [ ; we got a new connection ; let's add it to the list of output ports append output-ports first listen ] 'else [ ; some data incoming data: copy inputmulticast foreach port output-ports [ insert port data ] ] ] ] (You'll need to also handle the case of any of your output-ports being closed, and you'll probably want to figure out a way to tell the server to quit, etc.)