seed r481 - trunk/examples



Author: racarr
Date: Tue Dec 16 00:58:33 2008
New Revision: 481
URL: http://svn.gnome.org/viewvc/seed?rev=481&view=rev

Log:
Add Gnio server example.

Added:
   trunk/examples/Gnio-server.js   (contents, props changed)
Modified:
   trunk/examples/Makefile.am

Added: trunk/examples/Gnio-server.js
==============================================================================
--- (empty file)
+++ trunk/examples/Gnio-server.js	Tue Dec 16 00:58:33 2008
@@ -0,0 +1,41 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gnio");
+Seed.import_namespace("Gio");
+
+// I don't think this is the right way of doing things.
+var r = new Gnio.Resolver();
+var sock = new Gnio.Socket({domain: Gnio.SocketDomain.inet,
+						type: Gnio.SocketType.stream});
+
+
+var addr = r.lookup_name("localhost");
+						
+sock.bind(new Gnio.InetSocketAddress({address: addr,
+ 				                      port: 9999}));
+
+Seed.print("Echo server listening on port 9999");
+sock.listen(true);
+
+var client = sock.accept();
+
+Seed.print("Accepted client");
+
+ds = Gio.DataInputStream._new(new Gnio.SocketInputStream({socket: client}));
+os = Gio.DataOutputStream._new(new Gnio.SocketOutputStream({socket: client}));
+os.put_string("Seed echo server. Type quit to quit.\n");
+
+while(1)
+{
+	line = ds.read_line(null);
+	if (line.search("quit") > -1)
+	{
+		client.close();
+		Seed.quit();
+	}
+	os.put_string(line);
+	os.put_string("\n");
+}
+
+
+client.close();
+

Modified: trunk/examples/Makefile.am
==============================================================================
--- trunk/examples/Makefile.am	(original)
+++ trunk/examples/Makefile.am	Tue Dec 16 00:58:33 2008
@@ -6,6 +6,7 @@
 examples_DATA = \
 	actions.js \
 	Gnio.js \
+	Gnio-server.js \
 	clutter-cairo.js \ 
 	threaded-repl.js \
 	calculator.js \
@@ -32,6 +33,7 @@
 	video.js \
 	accelgroup.js \
 	Gnio.js \
+	Gnio-server.js \
 	clutter.js \
 	introspect.js \
 	poppler.js \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]