blob: d3722b768eade564678d049672f37aad6d0ab924 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// ============================================================================
//
// = PACKAGE
// tests.Connection
//
// = FILENAME
// ConnectorTest.java
//
// = AUTHOR
// Prashant Jain
//
// ============================================================================
package tests.Connection;
import java.io.*;
import java.net.*;
import ACE.OS.*;
import ACE.Connection.*;
public class ConnectorTest
{
void print_usage_and_die ()
{
System.out.println ("Usage: test_Connector <hostname> [<port>]");
System.exit (0);
}
public void init (String hostname, int port)
{
try
{
Connector connector = new Connector ();
connector.open (hostname, port);
connector.connect (new ClientHandler ());
}
catch (UnknownHostException e)
{
ACE.ERROR (e);
}
catch (SocketException e)
{
ACE.ERROR ("Connection refused");
}
catch (InstantiationException e)
{
ACE.ERROR (e);
}
catch (IllegalAccessException e)
{
ACE.ERROR (e);
}
catch (IOException e)
{
ACE.ERROR (e);
}
}
public static void main (String [] args)
{
int port = ACE.DEFAULT_SERVER_PORT;
ConnectorTest connectorTest = new ConnectorTest ();
if (args.length == 2)
{
try
{
port = Integer.parseInt (args[1]);
}
catch (NumberFormatException e)
{
connectorTest.print_usage_and_die ();
}
}
connectorTest.init (args[0], port);
}
}
|