Skip to content

Instantly share code, notes, and snippets.

@joneskoo
Created October 21, 2011 22:20
Show Gist options
  • Save joneskoo/1305130 to your computer and use it in GitHub Desktop.
Save joneskoo/1305130 to your computer and use it in GitHub Desktop.
UDP sender
#!/usr/bin/env python
import socket
import sys
PREFIX = "PREFIX:"
HOST = '127.0.0.1'
PORT = 5555
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((HOST, PORT))
with sys.stdin as f:
while True:
try:
s.send(PREFIX + f.readline())
except socket.error:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment