title: Getting a UDP socket program in Python to accept messages from a Syslog client?
body: <p>I'm trying to write a Syslog listener and so far so good on getting it to accept incoming messages through TCP but I also want UDP to function.</p>
  
  <p>This is the UDP server code I'm using, which works using a python client app. I also have another app which also works just using the python client app.</p>
  
  <pre><code># Server program
  # UDP VERSION
  
  
  from socket import *
  
  # Set the socket parameters
  host = "localhost"
  port = 514
  buf = 1024
  addr = (host,port)
  
  # Create socket and bind to address
  UDPSock = socket(AF_INET,SOCK_DGRAM)
  UDPSock.bind(addr)
  
  # Receive messages
  while 1:
      data,addr = UDPSock.recvfrom(buf)
      if not data:
          print "Client has exited!"
          break
      else:
          print "\nReceived message '", data,"'"
  
  # Close socket
  UDPSock.close()
  </code></pre>
  
  <p>Using this code I can send to the server and have it display the code.</p>
  
  <pre><code># Client program
  
  from socket import *
  
  # Set the socket parameters
  host = "localhost"
  port = 514
  buf = 1024
  addr = (host,port)
  
  # Create socket
  UDPSock = socket(AF_INET,SOCK_DGRAM)
  
  def_msg = "===Enter message to send to server===";
  print "\n",def_msg
  
  # Send messages
  while (1):
      data = raw_input('&gt;&gt; ')
      if not data:
          break
      else:
          if(UDPSock.sendto(data,addr)):
              print "Sending message '",data,"'....."
  
  # Close socket
  UDPSock.close()
  </code></pre>
  
  <p>I have tried the Kiwi Syslog Message Generator and Snare to send syslog messages to the UDP server and nothing comes up. Could someone help me understand?</p>