changeset 3:d7762f4e8bfa

redirect answer to client ok
author e165727 <e165727@ie.u-ryukyu.ac.jp>
date Thu, 13 Feb 2020 20:49:23 +0900
parents f3eb367c309f
children 1ad45c44e12f
files lib/Abyss/Server.pm6 other/client.p6 other/client.pl
diffstat 3 files changed, 51 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
--- 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<localhost>,
                                  :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;
--- /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;