Doesn't it look so simple?
Installation: take these four files (HelloObject.isl, HelloServer.cc, HelloClient.cc, and Imakefile) and place in an empty directory.
type:
ilumkmf
'ilumkmf' will generate a Makefile.
Note: On the HP-UX platform, there might be a couple warning...just ignore them.
type:
make
'make' will generate a couple files (HelloObject-server-stubs.py, HelloObject.H, HelloObject.cc.) Then it will attempt to compile everything.
To start the server type:
HelloServer &
The server will print out a bunch of garbage. This garbage is the binding handle the client needs in order to find the server anywhere on the Internet. You will need to use this handle as the first parameter [binding_handle} to HelloClient.
Note: The server needs to be place in the background with the '&' symbol at the end of the command line.
To start the client type:
HelloClient "[binding_handle]"
Note: remember to place double quotes around the binding_handle.
The client should print "Hello Stanford DL project from C++!" and exit. The server will continue to wait and process new hello messages.
INTERFACE HelloObject; TYPE Hello = OBJECT OPTIONAL METHODS hello () : ilu.CString END;
#include "HelloObject.H" #include/* I/O defs */ #include #include #include #include class HelloObjectImpl : public HelloObject_T_Hello { public: HelloObjectImpl(); // constructor virtual ~HelloObjectImpl(); // destructor // methods virtual ilu_CString hello (HelloObjectStatus *_status); // data slots private: }; HelloObjectImpl::HelloObjectImpl() { } HelloObjectImpl::~HelloObjectImpl() { } ilu_CString HelloObjectImpl::hello (HelloObjectStatus *_status) { char buf[1000]; sprintf(buf, "Hello Stanford DL Library from C++!"); _status->returnCode = HelloObjectReply_Success; return ((ilu_CString) strdup(buf)); } /***********************************************************************/ class HelloObjectObjTable : public virtual iluObjectTable { public: virtual iluObject * ObjectOfIH (ilu_CString ih); }; iluObject * HelloObjectObjTable::ObjectOfIH (ilu_CString ih) { return NULL; } /***********************************************************************/ main (int ac, char **av) { /* first, make a server object */ class iluServer s((ac > 1) ? av[1] : NULL, new HelloObjectObjTable); /* Do this, instead of overriding i.ILUGetServer */ ilu::SetDefaultServer(&s); /* now, add the only port */ s.AddPort ( (ac > 2) ? av[2] : NULL, (ac > 3) ? av[3] : NULL, ilu_TRUE); /* create an instance of the HelloObjectImpl object */ class HelloObjectImpl *i = new HelloObjectImpl; if (!i->ILUPublish()) { printf ("*** Error, couldn't publish object\n"); exit(1); } /* better print out the SBH to pass as arg to rwhoClient... */ printf ("%s\n", i->ILUStringBindingHandle()); /* and let things run... */ iluServer::Run(); /* should never return, but just in case: */ return(1); }
#include#include int main (int ac, char **av) { HelloObjectStatus status; if (ac < 2) { fprintf(stderr, "Usage: HelloClient \n"); return (1); } class HelloObject_T_Hello *m = HelloObject_T_Hello::ILUCreateFromSBH(av[1], NULL); if(m) { char *name = m->hello(&status); if (status.returnCode != NULL) { fprintf (stderr, "Exception \"%s\" (%d) signalled on request Name with server on machine %s.\n", status.returnCode, status.values.anyvalue, av[1]); return(0); } printf ("%s\n", name); delete m; } else { printf ("couldn't find instance of HelloObject.hello on host %s\n", av[1]); } return (0); }
NormalObjectRule() DependTarget() InterfaceTarget(HelloObject.isl) #ifdef ADD_CPLUSPLUS_LANGUAGE ILUCPlusPlusTarget(HelloObject.H HelloObject.cc HelloObject-server-stubs.cc, HelloObject.isl) ObjectTarget(HelloObject.o) ObjectTarget(HelloObject-server-stubs.o) HelloClient.o : HelloClient.cc HelloObject.H HelloServer.o : HelloServer.cc HelloObject.H ILUCPlusPlusProgramTarget(HelloClient, HelloClient.o HelloObject.o,,) ILUCPlusPlusProgramTarget(HelloServer, HelloServer.o HelloObject.o HelloObject-server-stubs.o,,) #endif