changeset 1:68307ce6839d

add some files
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 14 May 2012 13:22:21 +0900
parents 536b29f11352
children f85060c91817
files echoServer/echoServer.k msgpack/client.k msgpack/msgpack.k test/func.k test/in.k
diffstat 5 files changed, 100 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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();
 }
--- /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
--- /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
--- /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
--- /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