Relearning perl ,javascript!

OOP

Keep with studying!

小test routine:

------------------
#!/bin/perl -w
# Example of a daytime UDP server using perl functions
use Socket qw(INADDR_ANY AF_INET SOMAXCONN SOCK_DGRAM sockaddr_in inet_aton );
# Get protocol number
#my $proto = getprotobyname(’udp’);
# Create generic socket
socket(SOCK, AF_INET, SOCK_DGRAM, 17) or die "socket: $!";
# Bind to the daytime port on any interface
#my $port = getservbyname(’daytime’,’udp’);
my $port = 4000;
my $addr = inet_aton("192.1.1.201");
my $paddr = sockaddr_in($port, $addr);
#bind(SOCK, $paddr) or die "bind: $!";
# no listen() as that is a SOCK_STREAM call()
#$rin = "";
#vec($rin, fileno(SOCK), 1) = 1;

my $from = sockaddr_in(4001, $addr);
use strict;
    use CGI;
    my $q = new CGI;
   
 my $i = 0;
  print $q->header( "text/html" ),$q->start_html( "hello from perl cgi!" );
  #  print $q->h2("hello dave $i...");
   # print $q->end_html;
   
while ($i<60) {
#$from = recv(SOCK, $buffer, 1, 0) or next;
    send(SOCK, "AAAAAAAB\n", 0, $from) || die "send: $!";

    $i ++;
   
  #  print $q->h2("hello dave $i...");
}
 # print $q->end_html;