3 This program illustrates how to implement a simple client and server
4 using CORBA, IIOP, and synchronous method invocations (SMI). Client
5 applications can use this service to download and display files from a
6 CORBA server on the network. The core functionality of this program
9 * Client applications will use an iterator to download and display
10 files from a CORBA server one ``chunk'' at a time, rather
11 than in one large chunk. This design will help improve the
12 memory management overhead on the client and server.
14 * Operations in the IDL interface will use exceptions to propagate
15 problems back to clients.
17 * The CORBA Naming Service is used to bind and resolve object
18 references, rather than using a file.
20 The client program performs the following activities:
22 1. From the command-line, it reads the name of the pathname
23 you want to download. It then initializes the client-side
24 ORB and uses resolve_initial_references() to obtain a
25 reference to a Naming Service (which must be running). This
26 object reference is then downcast via _narrow() to an
27 object reference for a CosNaming::NamingContext interface,
28 which is then used to resolve the object reference that the
29 server bound earlier. After narrowing this to the Server
30 interface, the get_iterator() operation is called via the
31 object reference to obtain the Chunk_Iterator, which is
32 used to download the file.
34 2. When next_chunk() returns a chunk of the file, the contents
35 are written into a temporary file created in your a cache
36 (e.g., /tmp/yourloginname) on the local host. Then, an
37 external viewer is spawned to display the file. The type
38 of viewer to spawn is determined by examining the the
39 content_type_ metadata returned by the server.
41 The example can be run as follows:
43 1. Start the Name Service:
45 $ NameService -o /tmp/ns.ior
47 2. Start the SMI Content Server:
49 $ server -ORBInitRef NameService=file:///tmp/ns.ior
51 3. Request a file using the client:
53 $ client -ORBInitRef NameService=file:///tmp/ns.ior \
56 This particular example can only service one file at a time.
59 Server output should look like the following:
61 $ ./server -ORBInitRef NameService=file:///tmp/ns.ior
62 Bound <Iterator_Factory> to <IOR:010000002400000049444c3a57653625f5365727665722f4974657261746f725f466163746f72793a312e300001000000000000007c000000010102001400000076616c696e6f12722e6563652e7563692e65647500f39600001b00000014010f00525354bd9d4e39a6ac03000000000001000000010000000003000000000000000800000001000000004f4154010000001400000001ad85e4001000100000000000901010000000000004f41540400000001ac0000> in Name Service.
64 Received request for file: </home/myhome/foo.jpg>
65 Sending chunk 1 at offset <0> of size <8192>
66 Sending chunk 2 at offset <8192> of size <8192>
67 Sending chunk 3 at offset <16384> of size <8192>
68 Sending chunk 4 at offset <24576> of size <8192>
69 Sending chunk 5 at offset <32768> of size <4573>
72 Client output should look similar to:
74 $ ./client -ORBInitRef NameService=file:///tmp/ns.ior ~/foo.jpg
75 File </home/my_home/foo.jpg> has the following characteristics:
76 Modification Date: Wed, 01 Jan 2000 09:21:08 GMT
77 Content Type: image/jpeg
78 Spawned viewer <xv> with PID <10870>.