HOWTO's Home Development CORK Current users: guest (web) |
Connecting a clientThe client-side components of a CORK-based application communicate with the server via a class that implements the edu.vt.cs.collab.cork.ReplicatedObjectClientinterface. For servers that use the edu.vt.cs.collab.cork.impl.inet.ServerImpl class, the edu.vt.cs.collab.cork.impl.inet.InetClient provides the implementation of ReplicatedObjectClient.The constructor for InetClient takes three arguments:
ReplicatedObjectClient.login(...) method. By default, CORK server do not implement authentication, so any id/passwordpair will work. (Details on authentication support appear in a later section of this document.) The small program below (Client.java) creates a ReplicatedObjectClient that connects to a CORK server:
1 import edu.vt.cs.collab.cork.impl.inet.InetClient;
2 import edu.vt.cs.collab.cork.ReplicatedObjectClient;
3
4 /**
5 * Simple CORK client, with little error handling. Should be
6 * executed with server host and port number as arguments.
7 */
8 public class Client{
9 /**
10 * Our replicated object client
11 */
12 private ReplicatedObjectClient client = null;
13
14 public Client(String host, int port) {
15 try {
16 client = new InetClient(host, port, InetClient.SOCKET);
17 client.login("my-id", "my-password");
18 }
19 catch(SecurityException se) {
20 System.err.println("Login failed: ");
21 se.printStackTrace();
22 }
23 catch(Exception e) {
24 System.err.println("Client connection error: ");
25 e.printStackTrace();
26 }
27 }
28
29 public static void main(String[] args) {
30 int port = Integer.parseInt(args[1]);
31 Client c = new Client(args[0], port);
32 }
33 }
34
Note that this program doesn't actually do anything, it simply connects and logs in. |
| /public/chci/howto/cork/client.html | Login | Web Editor | Full Editor |
| Last modified 5/22/03 4:21 PM by isenhour (history) Site contents | |