I have a UDP server written in perl, I am trying to see the maximum load it can handle. I use a udp sender that reads a file and sends the message to the server , the server prints that message to the STDOUT.

When I send a burst of messages to the server I see some packets being dropped (netstat -su), I wanted to see how it works when I do the same in C and used This C program . When I run the C version it does not drop any message.


I thought the Perl socket used the underlying C libraries, So why does the perl version drop so many packets while the C version does not. Is there any way to make the perl version faster ?.


Here is the Perl version (example from Net::Server)
#!/usr/bin/perl =head1 NAME udp_server.pl - Simple sample udp echo server =head1 SERVER SYNOPSIS perl udp_server.pl --log_level 3 # default is to not background =cut package MyUDPD; use strict; use warnings; use Data::Dumper; my $port =32000; my $host = '0.0.0.0'; my $recv_length = 8192; # packet size use base qw(Net::Server::PreFork); ### run the server MyUDPD->run( port => "$host:$port/udp", min_servers => 10, ); exit; sub configure_hook { my $self = shift; ### change the packet len? $self->{server}->{udp_recv_len} = $recv_length; # default is 4096 } sub process_request { my $self = shift; my $prop = $self->{'server'}; print STDOUT $prop->{'udp_data'}; return; }
Thanks

In reply to Perl Socket Speed 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.