use IO::Socket to send UDP Packets.  Here's an example
from the Network Programming w/Perl book, page 535.

#!/usr/bin/perl
# file: udp_daytime_cli2.pl

use strict;
use IO::Socket qw(:DEFAULT :crlf);
use constant MAX_MSG_LEN => 100;
$/ = CRLF;
my $data;

my $host = shift || 'localhost';
my $port = shift || 'daytime';

my $sock = IO::Socket::INET->new(Proto  => 'udp',
                                                        => $host,
                                                        => $port) or die $@;

$sock->send('Yo!') or die "send() failed: $!\n";
$sock->recv($data,MAX_MSG_LEN) or die "recv() failed: $!\n";

chomp $data;
print $data,"\n";

--
Now run it:

% udp_daytime_cli2.pl host.domain.com
Wed Oct 2 17:10:34 2002

Cheers,

Carter.

> -----Original Message-----
> From: Harald Wopenka [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 02, 2002 4:29 PM
> To: [EMAIL PROTECTED]
> Subject: UDP
> 
> 
>  Hi there,
>  
>  looking for a little example how to send UDP-Pakets via 
> Perl. I found some
> nice things in perldoc, but they didn't work - or I was too dumb to
> implement them.
>  
>  Thanks in advance
> Harry
>  
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  • UDP Harald Wopenka
    • UDP Carter Thompson
    • UDP Harald Wopenka

Reply via email to