Last active
August 29, 2015 14:20
-
-
Save psyomn/c04ad560f4cf09557ab7 to your computer and use it in GitHub Desktop.
send messages using multiprocessing lib in python
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 sys | |
| from multiprocessing.connection import Client | |
| if len(sys.argv) == 1: | |
| print "Usage:" | |
| print " sendmsg.py <host> <port> <message>" | |
| print " sendmsg.py <message> (default port:5000, host:localhost)" | |
| args = sys.argv[1:] | |
| if len(args) >= 3: | |
| host = args[0] | |
| port = int(args[1]) | |
| mesg = args[2] | |
| else: | |
| host = 'localhost' | |
| port = 5000 | |
| mesg = args[0] | |
| address = (host, port) | |
| conn = Client(address) | |
| conn.send_bytes(mesg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment