1

I am trying to implement a socket server that receives rsyslog messages from windows or linux os. Ryslog uses omuxsock to output logs to socket server. I want to use twisted python to implement this socket that receives windows event/linux syslog messages. All the examples i've come across documentation only shows how to bind to IP and port. I want twisted socket to bind to a socket file not ip or port. eg., file "/var/syslog.sock"

in python without using twisted this can be done using:

s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
s.bind("/var/syslog.sock")

has anyone implemented socket in twisted python using socket file?

Sridev
  • 33
  • 7

1 Answers1

2

With a reactor that supports IReactorUNIX you can do this either with the lower-level listenUNIX or the higher level UNIXServerEndpoint.

For example

from twisted.internet import reactor
from twisted.internet.endpoints import UNIXServerEndpoint
from twisted.internet.protocols import Factory, Protocol

e = UNIXServerEndpoint(reactor, "/var/syslog.sock")
d = e.listen(Factory.forProtocol(Protocol))
reactor.run()
Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122