This version of your code implements the first two optimizations suggested by Chris Merck.
import socket, sys, itertools
host = sys.argv[1] #Server IP Address
textport = sys.argv[2] #Server Binding Port
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
port = int(textport)
except ValueError:
port = socket.getservbyname(textport, 'udp')
# preprocess file data
with open('auth3.log') as data:
roles = [role for (role, line_spoken) in line.split(': ', 1) for line in data]
# preprocess everything we can
hp = (host, port)
send = s.sendto
for role in itertools.cycle(roles):
try:
send(role, hp)
except:
pass
For further optimizations, you might want to process it using Cython, which might further speed up the loop. If the code still doesn't generate enough traffic, you'll probably need to launch several processes in parallel.