On Wed, Nov 18, 2009 at 5:05 AM, Leon Meyer <[email protected]> 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.)
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to