Skip to content

Instantly share code, notes, and snippets.

@antunesleo
Created December 19, 2017 13:07
Show Gist options
  • Save antunesleo/e0e52076c47f6d7bbd6df7cbcf713327 to your computer and use it in GitHub Desktop.
Save antunesleo/e0e52076c47f6d7bbd6df7cbcf713327 to your computer and use it in GitHub Desktop.
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