http://qs1969.pair.com?node_id=129545


in reply to Simple UDP example anyone?

Recipe 17.5 of the Perl Cookbook is handy:
use IO::Socket; use strict; my $sock = IO::Socket::INET->new( Proto => 'udp', PeerPort => 5000, PeerAddr => 'hostname', ) or die "Could not create socket: $!\n"; $sock->send('a file to have your advice') or die "Send error: $!\n";
perlipc has other examples. IO::Socket is slightly easier than Socket, and translating between the two isn't terribly difficult.

Replies are listed 'Best First'.
Re: Re: Simple UDP example anyone?
by mitd (Curate) on Dec 05, 2001 at 14:54 UTC
    $sock->send('a file to have your advice')
    Now thats what I call a datagram with a message.

    lol, chromatic++

    mitd-Made in the Dark
    'Interactive! Paper tape is interactive!
    If you don't believe me I can show you my paper cut scars!'

IO::Socket
by Ea (Chaplain) on Dec 05, 2001 at 16:44 UTC
    What few people mention is that IO::Socket doesn't work under Solaris (I believe that Sun has hardcoded the constants to non-standard values or similar rubbish) and you get stuck with using Socket

    Ea :wq

      IO::Socket actually does work under Solaris. I've been using it for XML servers on 4 different Solaris boxes ranging from 5.6 to 5.8. It's actually really sweet.
        I actually have done the same, and have successfully coded many a daemon to run on solaris systems. Sun can be very nice to you when you learn to use it.