# HG changeset patch # User e165727 # Date 1581594563 -32400 # Node ID d7762f4e8bfa809058b1357a50e4f9917ec326f6 # Parent f3eb367c309ff6e9dd24a7d89b8e366bc25e11be redirect answer to client ok diff -r f3eb367c309f -r d7762f4e8bfa lib/Abyss/Server.pm6 --- a/lib/Abyss/Server.pm6 Thu Feb 13 16:25:31 2020 +0900 +++ b/lib/Abyss/Server.pm6 Thu Feb 13 20:49:23 2020 +0900 @@ -22,31 +22,35 @@ loop { my $conn = $listen.accept; - my $start = now; - say "hoge"; - while my $buf = $conn.read(1024) - { - EVAL $buf.decode; - #$counter++; - last; - } + + #my $start = now; + + say "next recv msg"; + my $sock_msg; + + my $buf = $conn.recv(); + $sock_msg = $buf; + + say $sock_msg; + #my $end = now; + #EVAL $sock_msg; + #say $conn.native-descriptor(); close(1); dup2($conn.native-descriptor(), 1);#stdoutをsocketに切り替え + EVALFILE $sock_msg; #my $Time = $end - $start; #$sumTime = $sumTime + $Time; #say $Time; - say "send to Client"; + #say "hello"; + + #$conn.print: 'send to Client'; + #$conn.print: EVALFILE $sock_msg; + dup2($backup, 1); #file descripterを元に戻す close($backup); #backup消す - + $conn.close; - - #if ($counter == 10) - #{ - # say $sumTime; - # last; - #} } $listen.close; } diff -r f3eb367c309f -r d7762f4e8bfa other/client.p6 --- a/other/client.p6 Thu Feb 13 16:25:31 2020 +0900 +++ b/other/client.p6 Thu Feb 13 20:49:23 2020 +0900 @@ -1,8 +1,23 @@ use IO::Socket::Unix; +use NativeCall; my $conn = IO::Socket::Unix.new( :host, :port(3333) ); -$conn.print: 'say "Hello";'; -say $conn.read(1024); +$conn.print: '/Users/Koo/College/lab/Perl6/origin/Otoya-Server/other/fibonacci.p6'; + +my $sock_msg; + +while my $buf = $conn.recv(:bin) +{ + $sock_msg = $buf.decode; + last; +} + +say $sock_msg; + +#say $conn.recv; + + +#print $conn; #$conn.close; diff -r f3eb367c309f -r d7762f4e8bfa other/client.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/other/client.pl Thu Feb 13 20:49:23 2020 +0900 @@ -0,0 +1,14 @@ +#!/usr/bin/perl +use strict; +use warnings; +use IO::Socket; +use IO::Socket::UNIX; + +my $sock = IO::Socket::INET->new( + PeerAddr => 'localhost', + PeerPort => 3333, +) or die "hoge"; + +my $data; + +print $sock->getline;