Mercurial > projects > dreactor
view test/chatclient.d @ 9:5412a1ff2e49
adding chat client and more updates
author | rick@minifunk |
---|---|
date | Sat, 12 Jul 2008 10:42:41 -0400 |
parents | 2c6ab06a8829 |
children | d6a3cfe7c3de |
line wrap: on
line source
module chatclient; import tango.net.Socket; import tango.core.Thread; import tango.io.Stdout; import tango.io.Console; import tango.util.log.Log; import dreactor.core.Vat; import dreactor.core.Dispatcher; import dreactor.protocol.RawTcp; import dreactor.transport.AsyncSocketConduit; int main() { Vat c_vat = new Vat(); RawTCPClient client = new RawTCPClient(c_vat); Log.root.level(log.Level.Warn, true); client.setDataHandler( (char[] inbuf, Dispatcher d) { Stdout(inbuf)(); }); c_vat.run(); client.connect(new IPv4Address("localhost", 5555)); while(true) { char buf[] = Cin.copyln(true); if (buf == "quit\n") break; client.send(buf); } c_vat.exit(); delete client; return 0; }