7
|
1 module chatclient;
|
|
2
|
|
3 import tango.net.Socket;
|
|
4 import tango.core.Thread;
|
|
5 import tango.io.Stdout;
|
|
6 import tango.io.Console;
|
|
7 import tango.util.log.Log;
|
|
8
|
|
9 import dreactor.core.Vat;
|
|
10 import dreactor.core.Dispatcher;
|
|
11
|
|
12 import dreactor.protocol.RawTcp;
|
|
13 import dreactor.transport.AsyncSocketConduit;
|
|
14
|
|
15 int main()
|
|
16 {
|
|
17 Vat c_vat = new Vat();
|
|
18 RawTCPClient client = new RawTCPClient(c_vat);
|
|
19 Log.root.level(log.Level.Warn, true);
|
|
20
|
|
21 client.setDataHandler( (char[] inbuf, Dispatcher d) {
|
|
22 Stdout(inbuf)();
|
|
23 });
|
|
24
|
|
25 c_vat.run();
|
|
26 client.connect(new IPv4Address("localhost", 5555));
|
|
27
|
|
28 while(true)
|
|
29 {
|
|
30 char buf[] = Cin.copyln(true);
|
|
31 client.send(buf);
|
|
32 }
|
|
33 return 0;
|
|
34 }
|
|
35
|