Created
December 19, 2017 13:07
-
-
Save antunesleo/e0e52076c47f6d7bbd6df7cbcf713327 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 socket | |
import json | |
import sys | |
HOST = '0.0.0.0' | |
PORT = 9201 | |
try: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
except socket.error, msg: | |
sys.stderr.write("[ERROR] %s\n" % msg[1]) | |
sys.exit(1) | |
try: | |
sock.connect((HOST, PORT)) | |
except socket.error, msg: | |
sys.stderr.write("[ERROR] %s\n" % msg[1]) | |
sys.exit(2) | |
msg = {'@message': 'python test message', '@tags': ['test']} | |
sock.send(json.dumps(msg) + '\n') | |
sock.close() | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment