Search code examples
pythonnetwork-programmingtwisted

Python Twisted: read from file and send as TCP server


I am completely new to Twisted, but it looks very promising for my project.

I would like to write a Python Twisted application which reads a record from text file every x seconds and contemporary listen on a TCP port (acting as TCP server). If no clients are connected to the TCP server the records are just discarded. If one or more clients are connected to the TCP server, the records are sent to all clients (all clients will receive the same line of the text file)

Can Twisted make this possible with a reasonable amount of LOCs?

Could anybody suggest an example to start with?

Thanks C


Solution

  • Twisted's documentation includes information about how to run a TCP server. It also includes an information about how to perform work based on the passage of time. This should cover most of what you need to know.