Hi Monks, I want to have a IO::Socket::Multicast-Server sending its info to some clients or users.
But how can I have this multicast-socket-server normally waiting for its clients to connect?

The example-code is described as: "The following is an example of a multicast server.
Every 10 seconds it transmits the current time and the list of logged-in users to the local network
using multicast group 226.1.1.2, port 2000 (these are chosen arbitrarily)."

But when the users were logging in? Before $sock was created? Ant where and how could they have logged in?

#!/usr/bin/perl # server use strict; use IO::Socket::Multicast; use constant DESTINATION => '226.1.1.2:2000'; my $sock = IO::Socket::Multicast->new(Proto=>'udp',PeerAddr=>DESTINAT +ION); while (1) { my $message = localtime; $message .= "\n" . `who`; $sock->send($message) || die "Couldn't send: $!"; } continue { sleep 10; }
Using google I couldn't even found sample code of others.
I tried s.th like:
while( !$sock->connected ) {sleep 1; }
which dies because "$sock is not defined" ...

My target is a server program that collects data form its own sources (by pipes)
saves them into files and distribute them to several clients (or users) if there are any.

I have had a solution by using normal sockets and threads-shared, but after the threads-module was updated
it now stops as soon as the first client drops its connection.

Your help is highly appreciated, because this is source of my data..
Thanks a lot in advance,
Carl


In reply to need Socket::Multicast-help by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.