I'm searching for a way to open a TCP connection, send a HTTP post request and keep the connection open.
It would be great if I can achieve this without administrator/root rights, from a command-line interface (CLI), cross-platform and with passing parameters.
Some background info. I managed to rebuild a direct HTTP request towards an Apple TV, in order to get a supported HTTP live stream started. In the same way as AirPlay works. I tested this in two different ways, and so I have a proof-of-concept using telnet and using PHP sockets. I want to make an open-source GitHub project adding the source-code and a small GUI (compiled executable for Linux, OSx and Windows) so that users can fill in any supported streaming URL and send it directly to their AppleTV.
A cross-platform solution will consist of at least a working executable/script for Windows, OSx and Linux. Accepting some kind of target and source, for example:
./persistent_tcp.sh -t 192.168.1.10:7000 -s http://example.com/stream.m3u8 ./persistent_tcp.exe -t 192.168.1.10:7000 -s http://example.com/stream.m3u8
Inside the script I would like to specify the exact HTTP request, using the
-s argument as a target stream (value in the HTTP request). Ideally it would return some kind of PID and continue instead of keeping the process "visibly" open or waiting. With the PID, I'm able to close the previous PID when a new one is started. Although this isn't necessary.
A new request will overrule the previous one on AppleTV anyway, but I want that processes cleaned up also. The reason why I want a cross-platform solution is that I can integrate it into different cross-platform GUIs as well as offering cross-platform CLI scripts to do so.
I checked out different solutions but
wget, including their Windows ports don't really seem to be able to do so. Telnet on windows works perfectly fine as long as the terminal/connection is open (and the user has enough rights) and PHP sockets work like a charm as long as the process/connection stays open. I don't want to use, embed PHP (although it is cross-platform) because I consider it a huge dependency (read: too big for such a task).
I don't care in what programming language I can achieve this. As long as it is efficient (read: small footprint) and not requiring too many dependencies or resources. Since that won't fit such a small task. Alternatively I'm also fine with a separate solution for Windows and one for Linux/OSx).
I'm fine with bash/sh, bat/cmd/vbs, apple script, node.js and other languages or pre-compiled or standalone/portable executable that fit the job and don't require the client to install additional software. (I can probably embed PHP, Python or Java as stand-alone, but key is efficiency. Nobody will be happy if we end up with a 50mb GUI executable, while the actual HTTP request is less then 10 lines code.)