Reputation: 9932
I'm trying to forward UDP traffic over TCP using socat
. I know that frame boundaries will be lost by this process, but this is not an issue in this case. I managed to get it partially working using this command:
socat TCP-LISTEN:20000,fork UDP4-LISTEN:10000,reuseaddr
I.e., socat
waits for a client to connect to the TCP socket, then forks a new child process which listens on the UDP socket. Multiple clients should be able to connect using TCP and every client should get every received UDP message. This works as long as only a single endpoint is sending data to the UDP socket. But if a second endpoint is sending data to the UDP socket, that data will not be forwarded over an already established TCP connection.
It seems that socat
calls connect()
on the UDP socket in a forked child process as soon as it receives the first packet or otherwise filters data sent from other hosts.
Is there any way to instruct socat
to not filter UDP traffic and forward packets from any endpoint sent to the listening UDP socket?
Upvotes: 0
Views: 1853
Reputation: 41
I don't think this can be done with socat, also I don't see the "reuse" option even in my 2.0.0-b4 version.
Assuming the command:
socat TCP-LISTEN:20000,fork,reuseaddr UDP-RECVFROM:10000,reuseaddr
As far as I can see in my system this will not send the UDP messages to all the TCP connected clients. It will just send the messages from one UDP client to one TCP client at a time, once next UDP client connects it will send data to the next TCP client only.
Upvotes: 0