[Assorted-commits] SF.net SVN: assorted: [696] sandbox/trunk/src/cc
Brought to you by:
yangzhang
|
From: <yan...@us...> - 2008-05-02 03:13:07
|
Revision: 696
http://assorted.svn.sourceforge.net/assorted/?rev=696&view=rev
Author: yangzhang
Date: 2008-05-01 20:13:14 -0700 (Thu, 01 May 2008)
Log Message:
-----------
added basic tamer demo
Added Paths:
-----------
sandbox/trunk/src/cc/tamer/
sandbox/trunk/src/cc/tamer/basics.tt
Added: sandbox/trunk/src/cc/tamer/basics.tt
===================================================================
--- sandbox/trunk/src/cc/tamer/basics.tt (rev 0)
+++ sandbox/trunk/src/cc/tamer/basics.tt 2008-05-02 03:13:14 UTC (rev 696)
@@ -0,0 +1,42 @@
+#include <iostream>
+#include <boost/scoped_array.hpp>
+#include <commons/check.h>
+#include <commons/die.h>
+#include <tamer/tamer.hh>
+#include <tamer/fd.hh>
+#include <tamer/bufferedio.hh>
+
+using namespace std;
+using namespace boost;
+using namespace commons;
+using namespace tamer;
+using namespace tamer::fdx;
+
+const int port = 8989;
+
+class C
+{
+ tamed void f() { return 0; }
+};
+
+tamed void
+go()
+{
+ tvars { fd listener, conn; }
+ twait { tcp_listen(port, make_event(listener)); }
+ checkdie(listener, "listen");
+ while (1) {
+ twait { listener.accept(0, 0, make_event(conn)); }
+ checkdie(conn, "accept");
+ cout << "handling" << endl;
+ }
+}
+
+int
+main()
+{
+ initialize();
+ go();
+ loop();
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|