view lib/Abyss/Server.pm6 @ 0:11ef16a351e6

move from otoya
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 17 Jan 2020 12:11:01 +0900
parents
children e23d55b94840
line wrap: on
line source

use v6.c;
unit class Abyss::Server:ver<0.0.1>:auth<cpan:ANATOFUZ>;

use MONKEY-SEE-NO-EVAL;

method readeval {
  my $listen = IO::Socket::INET.new( :listen,
                                     :localhost<localhost>,
                                     :localport(3333) );
  my $counter = 0;
  my $now = DateTime.now(formatter => { sprintf "%03d:%03d:%03d", .hour, .minute ,.second});
  loop {
      my $conn = $listen.accept;
          while my $buf = $conn.read(1024) {
              EVALFILE $buf.decode;
              $counter++;
          }
      $conn.close;

      if ($counter == 100) {
       last;
      }
  }
  $now = DateTime.now(formatter => { sprintf "%03d:%03d:%03d", .hour, .minute ,.second});
  say $now;

}


=begin pod

=head1 NAME

Abyss::Server - blah blah blah

=head1 SYNOPSIS

=begin code :lang<perl6>

use Abyss::Server;

=end code

=head1 DESCRIPTION

Abyss::Server is ...

=head1 AUTHOR

AnaTofuZ <anatofuz@gmail.com>

=head1 COPYRIGHT AND LICENSE

Copyright 2020 AnaTofuZ

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

=end pod