Created
June 15, 2018 16:13
-
-
Save lironsade/1f0770bdf66c90a1b7d59d985a92f9f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
server_args = ['whatsappServer', '8875'] | |
client1_args = ['whatsappClient', 'client1', '127.0.0.1', '8875'] | |
client2_args = ['whatsappClient', 'client2', '127.0.0.1', '8875'] | |
def main(): | |
server = subprocess.Popen(server_args, | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
universal_newlines=True, | |
bufsize=0) | |
c1 = subprocess.Popen(client1_args, | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
universal_newlines=True, | |
bufsize=0) | |
c2 = subprocess.Popen(client2_args, | |
stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
universal_newlines=True, | |
bufsize=0) | |
c1.stdin.write('send client2 hello') | |
print(server.stdout.readline()) | |
print(server.stdout.readline()) | |
print(server.stdout.readline()) | |
server.stdin.close() | |
c1.stdin.close() | |
c2.stdin.close() | |
server.stdout.close() | |
c1.stdout.close() | |
c2.stdout.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment