Advertisement
kadytoast

hostmain

Aug 23rd, 2021 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. import socketserver as soss
  2. import threading as th
  3. import socket as sock
  4. import testconnhandling as handler
  5. import testqueuemanager as qman
  6.  
  7. cam = "cam!@#"
  8. keypad = "key!@#"
  9. motion = "mot!@#"
  10. controller = "con!@#"
  11.  
  12. packetdelim = "&%&%("
  13. flag_internaldelim = "%^&*)"
  14. datadelim = "!&^%!"
  15. dictflag = "fdict"
  16. picflag = "fpic"
  17. newconflag = "fcon"
  18. commflag = "fcommd"
  19.  
  20. # initializing the process/queue manager classes
  21. servermanager = qman.QueueManager()
  22.  
  23. buffer = 8192
  24.  
  25. #inconsequential
  26. def terminalprompt():
  27.     print("terminal entered")
  28.     while True:
  29.         command = input(">")
  30.  
  31.         if command == "show":
  32.             print(servermanager, "terminalprompt")
  33.             print("current process dictionary \n", servermanager.procdict)
  34.  
  35.  
  36.         else:
  37.             if command != "":
  38.                 print(f"command '{command}' not found, use 'help' for information")
  39.  
  40. class ThreadedTcpServer(soss.ThreadingMixIn, soss.TCPServer):
  41.     pass
  42.  
  43. if __name__ == "__main__":
  44.  
  45.    
  46.     # addr defined
  47.     host, port = "0.0.0.0", 6280
  48.     # making the socket object and setting it to server forever
  49.     with ThreadedTcpServer((host, port), handler.ConnHandler, bind_and_activate=False) as server:
  50.        
  51.  
  52.         # server socket handler thread starting
  53.         server.allow_reuse_address = True
  54.         server.server_bind()
  55.         server.server_activate()
  56.  
  57.         serverthread = th.Thread(target=server.serve_forever, args=(1,))
  58.         serverthread.start()
  59.  
  60.  
  61.  
  62.         # terminal prompt start
  63.         terminalprompt()
  64.  
  65.        
  66.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement