Create UDP to TCP bridge with socat/netcat to relay control commands for vlc media-player
I suspect your problem is more because whatever sends the UDP packets is not adding a newline character the commands (as in they should send "play\n"
and not just "play"
).
In any case, if you want a new TCP connection to be created for each of the UDP packets, you should use udp-recvfrom
instead of udp-listen
in socat
:
socat -u udp-recvfrom:3333,fork tcp:localhost:50000
Then every UDP packet should trigger one TCP connection that is only brought up to send the content of the packet and then closed.
Test by doing:
echo play | socat -u - udp-sendto:localhost:3333
(which sends a UDP packet whose payload contains the 5 bytes "play\n"
).
Related videos on Youtube
Mihai Popescu
Updated on September 18, 2022Comments
-
Mihai Popescu over 1 year
The UDP - must listen on port. The TCP - must connect to a server.
I tried
netcat
andsocat
.nc -v -u -l -p 3333 | nc -v 127.0.0.1 50000 socat -v UDP-LISTEN:3333,fork TCP:localhost:50000
Both work -- they delivered the message -- but the line is not ended. VLC will only take the command if I close netcat/socat.
I monitored the connection with
sockettest
and the messages are one after another in the same line, like this:playpausestopexitadd
I need the line to be ended so that the message transmitted looks like this:
play stop exit add
Maybe the packet is not ended?
I am wondering if
nc
orsocat
have options to send the packet/end line after a certain amount of time.If I add
\n
to the output as suggested by @roaima, I getplay\nstop\nplay\n
on a single line.