The UDP – must listen on port.
The TCP – must connect to a server.
I tried netcat
and socat
.
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
or socat
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 get play\nstop\nplay\n
on a single line.
Best Answer
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 ofudp-listen
insocat
: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:
(which sends a UDP packet whose payload contains the 5 bytes
"play\n"
).