pyhello - a very simple python hello client/server object.

This ILU application 'pyhello' is written in python. It defines one interface 'HelloObject', one class 'Hello', and one method 'hello'. This application is composed of a server and a client. The server's responibility is to serve to all of its clients the phrase "Hello Stanford DL Library from Python" when the 'hello' method is called on 'Hello'. The client just need to know how to get to the server and call the right method in order to receive this wonderful greeting.

Doesn't it look so simple?

Installation: take these four files (HelloObject.isl, HelloObjectServer.py, HelloObjectClient.py, 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.py and HelloObject__skel.py.)

To start the server type:

	python HelloObjectServer.py &

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 HelloObjectClient.py.

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:

	python HelloObjectClient.py "[binding_handle]" 

Note: remember to place double quotes around the binding_handle.

The client should print "Hello Stanford DL project!" and exit. The server will continue to wait and process new hello messages.


The Code


HelloObject.isl


INTERFACE HelloObject;

TYPE Hello = OBJECT OPTIONAL
	METHODS
		hello () : ilu.CString
	END;

HelloObjectServer.py


#!/usr/local/bin/python
#

import os, socket, sys, ilu, HelloObject__skel

class Hello(HelloObject__skel.Hello):
    def hello(self):
	return "Hello Stanford DL Project!";

def main(argv):
    server = ilu.CreateServer(None, None, None);

    mach = Hello()
    print mach.IluSBH()

    ilu.RunMainLoop()

main(sys.argv)

HelloObjectClient.py


#!/usr/local/bin/python
#

import sys, ilu, HelloObject

argc = len(sys.argv)
if argc < 2:
    print 'usage:', sys.argv[0], '[sbh-machine1]'
    sys.exit(1)

HelloObjectInstance = ilu.ObjectOfSBH(HelloObject.Hello, sys.argv[1])

print HelloObjectInstance.hello()
print



Imakefile


NormalObjectRule()
DependTarget()

InterfaceTarget(HelloObject.isl)

#ifdef ADD_PYTHON_LANGUAGE

ILUPythonTarget(HelloObject.py HelloObject__skel.py, HelloObject.isl)
all:: HelloObject.py HelloObject__skel.py

#endif