perl6 Socket: 发送HTTP请求

复制代码
sub MAIN(Str $host,Str $path,  Int $port) {
  my $send = "GET $path HTTP/1.1\r\nHost: $host\r\n\r\n";
  my $c = IO::Socket::INET.new(:host($host), :port($port));
  $c.print: $send;
  while (my $buff = $c.recv(1024)) {
    say $buff.print;
  }
  $c.close;
}
复制代码

 

posted on   Perl6  阅读(253)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示