views:

233

answers:

1

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.

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.

# 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()

Using this code I can send to the server and have it display the 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('>> ')
    if not data:
        break
    else:
        if(UDPSock.sendto(data,addr)):
            print "Sending message '",data,"'....."

# Close socket
UDPSock.close()

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?

+1  A: 

Found the problem, the code was perfect, just the Kiwi Syslog Message Generator I was using wasnt working. Along with the Kiwi Syslog Server comes an awesome probram called Log Forwarder designed to forward all sorts of event messages (way beyond what the event viewer has to offer) to a syslog server. That one also has a test feature... which works :)

Elvar