def main_server(SERVER_PORT): #start broadcaster SERVER_MAC, SERVER_IP = status.getName() broadcast_message = SERVER_PORT print "SERVER MAC", SERVER_MAC print "SERVER IP ", SERVER_IP bserver = broadcast_server( str(broadcast_message) ) bserver.daemon = True bserver.start() try: while True: time.sleep( 100 ) except (KeyboardInterrupt, SystemExit): print "clear" bserver.kill_received = True print "joining" bserver.join() print "bye" sys.exit(0) print "exit"
def main_server(SERVER_PORT): #start broadcaster SERVER_MAC, SERVER_IP = status.getName() broadcast_message = SERVER_PORT print "SERVER MAC", SERVER_MAC print "SERVER IP ", SERVER_IP bserver = broadcast_server(str(broadcast_message)) bserver.daemon = True bserver.start() try: while True: time.sleep(100) except (KeyboardInterrupt, SystemExit): print "clear" bserver.kill_received = True print "joining" bserver.join() print "bye" sys.exit(0) print "exit"
#https://github.com/imatix/zguide/tree/master/examples/Python if os.path.basename( __file__ ) in [ 'server.py' ]: print "server mode" main_server(SERVER_PORT) elif os.path.basename( __file__ ) in [ 'client.py' ]: print "client mode" print " - importing urllib2" import urllib2 dbPath = status.dbPath pycklerext = status.pycklerext myName = status.getName() print " name:", myName main_client( dbPath, pycklerext, myName ) #class ServerTask(threading.Thread):
#http://zguide.zeromq.org/py:taskwork #http://zguide.zeromq.org/py:tasksink #https://github.com/imatix/zguide/tree/master/examples/Python if os.path.basename(__file__) in ['server.py']: print "server mode" main_server(SERVER_PORT) elif os.path.basename(__file__) in ['client.py']: print "client mode" print " - importing urllib2" import urllib2 dbPath = status.dbPath pycklerext = status.pycklerext myName = status.getName() print " name:", myName main_client(dbPath, pycklerext, myName) #class ServerTask(threading.Thread): # """ServerTask""" # def __init__(self): # threading.Thread.__init__ (self) # self.kill_received = False # # def run(self): # context = zmq.Context() # frontend = context.socket(zmq.ROUTER) # frontend.bind('tcp://*:5570') #