def hello(ip,port,sockobj, thiscommhandle,listencommhandle):
sockobj.recv(512) # Receive HTTP header
htmlresponse = "
Hello World" + \
" Hello World!
"
sockobj.send("HTTP/1.1 200 OK\r\nContent-type: text/html\r\n" + \
"Content-length: %i\r\n\r\n%s" % (len(htmlresponse), htmlresponse))
stopcomm(thiscommhandle)
# close my connection with this user (we could also do sockobj.close())
if callfunc == 'initialize':
if len(callargs) > 1:
raise Exception("Too many call arguments")
# Running remotely:
# whenever this vessel gets a connection on its IPaddress:GENIport it'll call hello
elif len(callargs) == 1:
port = int(callargs[0])
ip = getmyip()
# Running locally:
# whenever we get a connection on 127.0.0.1:12345 we'll call hello
else:
port = 12345
ip = '127.0.0.1'
listencommhandle = waitforconn(ip,port,hello)