Revision: 506
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=506&view=rev
Author: bharling
Date: 2007-12-17 10:03:12 -0800 (Mon, 17 Dec 2007)
Log Message:
-----------
Updated to the latest version of the showcase demo.
A little speed improvement.
-bharling
Added Paths:
-----------
trunk/python-ogre/demos/showcase_01/prospector.py
Added: trunk/python-ogre/demos/showcase_01/prospector.py
===================================================================
--- trunk/python-ogre/demos/showcase_01/prospector.py (rev 0)
+++ trunk/python-ogre/demos/showcase_01/prospector.py 2007-12-17 18:03:12 UTC (rev 506)
@@ -0,0 +1,41 @@
+import socket as s
+import SocketServer as ss
+import random
+
+NAMES = ['Whittle', 'Bark', 'Chafer', 'Cap', 'Bolete', 'Willow', 'Chestnut',
+ 'Sunny', 'Lemon', 'Spotted', 'Morsel', 'Gummy', 'Fibrous' 'Old-Mans',
+ 'Death', 'Mulch']
+
+class ProspectingManager(ss.BaseRequestHandler):
+ def handle(self):
+ try:
+ datain = self.request[0] # get the input string
+ s=datain.split() ## Assume input data is <count><space><rest of info>
+
+ sock = self.request[1] ## this is the incomming socket
+
+ fname = random.choice(NAMES) + ' ' + random.choice(NAMES)
+
+ ## because this is a UDP demo we need to connect to send info back
+ ## I suspect this isn't needed if we use TCP server
+ #sock.connect ( self.client_address )
+
+ sock.send (fname) ## send data back
+ except:
+ pass
+
+
+
+class Server(ss.ThreadingMixIn, ss.TCPServer): pass
+
+if __name__ == "__main__":
+ # we create a server on the local machine listening to port 4444..
+ # could also use "localhost" instead of gethostname()
+ (family, socktype, proto, canonname, sockaddr) = s.getaddrinfo ( "127.0.0.1", 4444 )[0]
+ myServer = Server ( sockaddr, ProspectingManager )
+ myServer.closenow = False
+ print 'Server Started'
+ while not myServer.closenow:
+ myServer.handle_request()
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|