1 package org.indy;
2
3 import org.indy.util.IndyUtilities;
4 import org.indy.io.*;
5
6 /***
7 * Description of the Class
8 *
9 *@author owen
10 */
11 public class TestTCPServer {
12
13 /***
14 * Constructor for the IdTCPServerTest object
15 */
16 public TestTCPServer() { }
17
18 /***
19 * The main program for the IdTCPServerTest class
20 *
21 *@param args The command line arguments
22 */
23 public static void main(String[] args) {
24 TCPServer server = new TCPServer();
25
26 server.addServerExecuteListener(
27 new TCPServerExecuteListener() {
28 public void onExecute(TCPServer sender,TCPServerConnection connection) throws IndyException{
29 try {
30 connection.writeLine("Hello");
31 }
32 catch (Exception e) {
33 throw new IndyException(e);
34 }
35 }
36 });
37
38 try {
39 server.setActive(true);
40 }
41 catch (IndyIOException ex) {
42 ex.printStackTrace();
43 return;
44 }
45
46 TCPClient client = new TCPClient();
47
48 client.setHost("127.0.0.1");
49 client.setPort(6666);
50 try {
51 client.connect();
52 System.err.println(client.readLine(0, 1024));
53 System.err.println(client.readLine(0, 1024));
54 client.disconnect();
55 server.setActive(false);
56 }
57 catch (Exception e) {
58 e.printStackTrace();
59 }
60 }
61 }
This page was automatically generated by Maven