Allow schema files that are missing checksums on the !!SCHEMAMATIC line.
[versaplex.git] / wvdotnet / streamtest.cs
blob081efbb1834828ad204e7a33ec2fbed23779a18f
1 /*
2 * Versaplex:
3 * Copyright (C)2007-2008 Versabanq Innovations Inc. and contributors.
4 * See the included file named LICENSE for license information.
5 */
6 using System;
7 using System.Collections;
8 using Wv;
9 using Wv.Extensions;
11 public class FooTest
13 static IEnumerable contprint(WvLog log, WvStream s, string prefix)
15 int i = 0;
16 while (s.ok)
18 i++;
19 string str = s.read(128).FromUTF8();
20 log.print("{0}#{1}: {2}\n", prefix, i, str);
21 yield return 0;
25 public static void Main()
28 Console.WriteLine("stdout works.");
29 Console.OpenStandardError().write("stderr works.\n".ToUTF8());
31 WvLog log = new WvLog("main");
32 log.print("Hello");
33 log.print(" world!\n");
35 WvStream s1 = new WvTcp("localhost", 80);
36 WvStream s2 = new WvTcp("localhost", 80);
37 s1.onreadable += contprint(log, s1, "\nA\n").ToAction();
38 s2.onreadable += contprint(log, s2, "\nB\n").ToAction();
39 s1.print("GET / HTTP/1.0\r\n\r\n");
40 s2.print("FOO / HTTP/1.0\r\n\r\n");
41 while (s1.ok || s2.ok)
42 WvStream.runonce();
43 log.print("\n");
44 log.print("s1 err: {0}\n", s1.err.Short());
45 log.print("s2 err: {0}\n", s2.err.Short());