Guest User

Untitled

a guest
Jun 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import subprocess
  2.  
  3.  
  4.  
  5. server_args = ['whatsappServer', '8875']
  6. client1_args = ['whatsappClient', 'client1', '127.0.0.1', '8875']
  7. client2_args = ['whatsappClient', 'client2', '127.0.0.1', '8875']
  8.  
  9.  
  10. def main():
  11. server = subprocess.Popen(server_args,
  12. stdin=subprocess.PIPE,
  13. stdout=subprocess.PIPE,
  14. stderr=subprocess.PIPE,
  15. universal_newlines=True,
  16. bufsize=0)
  17.  
  18. c1 = subprocess.Popen(client1_args,
  19. stdin=subprocess.PIPE,
  20. stdout=subprocess.PIPE,
  21. stderr=subprocess.PIPE,
  22. universal_newlines=True,
  23. bufsize=0)
  24.  
  25.  
  26. c2 = subprocess.Popen(client2_args,
  27. stdin=subprocess.PIPE,
  28. stdout=subprocess.PIPE,
  29. stderr=subprocess.PIPE,
  30. universal_newlines=True,
  31. bufsize=0)
  32.  
  33. c1.stdin.write('send client2 hello')
  34. print(server.stdout.readline())
  35. print(server.stdout.readline())
  36. print(server.stdout.readline())
  37.  
  38. server.stdin.close()
  39. c1.stdin.close()
  40. c2.stdin.close()
  41. server.stdout.close()
  42. c1.stdout.close()
  43. c2.stdout.close()
  44.  
  45.  
  46. if __name__ == '__main__':
  47. main()
Add Comment
Please, Sign In to add comment