Using socat to exchange data via UDP

I had a case where I had to exchange a file via UDP socket, and for that to work I had to find out a tool (without writing new one) that can do that. As socat is well known tool that enables transfers using various protocols, I just had to figure out the command line flags.

And here’s what I found out (via man page).

On the client side (which is behind NAT), invoke command which will send datagram with OK, and open NAT tunnel.

echo "OK" | socat -t 1000 -  UDP4-sendto:1.2.3.4:6666

On server side, which is public IP address, and listening on port, invoke this. This command will when it receives a datagram, start sending datagram packages at rate defined with pv command.

pv -L 200k /var/some/file.zip | socat -b 1024 - udp4-recvfrom:6666

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *