First let me say that I am not a programmer but I have always been able to accomplish what I've needed with Python. My current project is a network encoder for SageTV. SageTV PVR sends commands to a network encoder running on port 4510 which in turn tunes a capture card, then starts ffmpeg recording based on parameters passed. It then continues to listen for further instructions and processes those commands.
I have set up SageTV and can communicate using netcat. This is the output using netcat:
root@debian# nc -l -k -p 4510
VERSION
1
STOP
OK
In the above example. The SageTV server replied 'VERSION' and I typed '1' then it replied 'STOP' and I replied 'OK'.
I have been trying to find a good example of how to convert what netcat is doing into a Python script. I've found various examples but I just can't find one that will listen and even just show what the server is showing. Can someone show me or point me to a good example? I know this should be really easy to do but I've been banging my head on this with no luck. Any help would be greatly appreciated.
socket(7)to get an idea of what netcat is actually doing. Then take a brief look atsocketbefore continuing on toasyncioand/orsocketserver.