# HG changeset patch # User Nobuyasu Oshiro # Date 1336969341 -32400 # Node ID 68307ce6839d83c215f7e60a1cd58e06b3e26a28 # Parent 536b29f11352c5db997abe857c4a349451f83b50 add some files diff -r 536b29f11352 -r 68307ce6839d echoServer/echoServer.k --- a/echoServer/echoServer.k Sat Apr 28 21:01:53 2012 +0900 +++ b/echoServer/echoServer.k Mon May 14 13:22:21 2012 +0900 @@ -9,7 +9,7 @@ print "accept..." Socket sock = servSock.accept(); - print "accepted" + print "client connected" InputStream in = sock.getInputStream(); OutputSteram out = sock.getOutputStream(); @@ -20,4 +20,6 @@ out <<< b <<< EOL; out.flush(); } + out.close(); + in.close(); } diff -r 536b29f11352 -r 68307ce6839d msgpack/client.k --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/msgpack/client.k Mon May 14 13:22:21 2012 +0900 @@ -0,0 +1,30 @@ +using konoha.io.*; +using konoha.socket.*; + + +void main(String[] args) { + int port = 8888; + String host = "localhost"; + print "client program"; + print "port number = " + port; + + print "conect to " + host + "..."; + Socket sock = new Socket("localhost", port); + + InputStream in = sock.getInputStream(); + OutputSteram out = sock.getOutputStream(); + + String cmd = "Math.sin(45)"; + print cmd; + out.writeMsgPack(cmd); + + out.flush(); + while ( !in.isClosed() ) { + String ret =in.readLine(); + print ret; + } + + out.close(); + + in.close(); +} \ No newline at end of file diff -r 536b29f11352 -r 68307ce6839d msgpack/msgpack.k --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/msgpack/msgpack.k Mon May 14 13:22:21 2012 +0900 @@ -0,0 +1,26 @@ +using konoha.io.*; +using konoha.socket.*; +using konoha.math.*; + +void main(String[] args) { + int port = 8888; + print "port number = " + port; + + ServerSocket servSock = new ServerSocket(port, 1); + + print "accept..."; + Socket sock = servSock.accept(); + print "client connected"; + + InputStream in = sock.getInputStream(); + OutputSteram out = sock.getOutputStream(); + + while ( !in.isClosed() ) { + String val = in.readMsgPack(); + print val; + out <<< val <<< EOL; + out.flush(); + } + out.close(); + in.close(); +} \ No newline at end of file diff -r 536b29f11352 -r 68307ce6839d test/func.k --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/func.k Mon May 14 13:22:21 2012 +0900 @@ -0,0 +1,27 @@ +void funcB(); + +void func() +{ + funcB(); +} +void funcB() +{ + print "test" +} + +var f = function(String str) { + print str; +}; + +var g = function() { + return 3; +} + + +void main(String[] args) +{ + func(); + f("function"); + int num = g(); + print num +} \ No newline at end of file diff -r 536b29f11352 -r 68307ce6839d test/in.k --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/in.k Mon May 14 13:22:21 2012 +0900 @@ -0,0 +1,14 @@ +using konoha.io.*; + +void main(String[] args) +{ + InputStream in = new InputStream("text.txt"); + Bytes buf; + int length = 10; + in.readFile(); + in.read(buf,length); + print buf; + print in.readLine(); + + +} \ No newline at end of file