Hello,
I'm trying to broadcast a files contents to a UDP broadcast address using netcat (nc)
cat filename|nc -u 192.168.1.255 4444
netcat just exits with errorlevel 1
I have been able to do this on the windows port of netcat!
Does anyone know why this is not working?
Or an alternative method I could use to send a file to broadcast address?
Thanks,
E
netcat UDP broadcast
Re: netcat UDP broadcast
Since I found this thread while doing internet searches but no answer was posted, I'll let you know that this seems to be a long-standing bug in netcat (at least GNU netcat):
http://sourceforge.net/p/netcat/bugs/8/
echo "UDP broadcast" | socat - UDP4-DATAGRAM:192.168.0.255:11001,so-broadcast
which pipes "UDP broadcast" from echo (followed by \n) to socat, which has STDIN as input ("-"). Then outputs to UDP4-DATAGRAM on the broadcast address (192.168.0.255) with the "so-broadcast" flag. There are a bunch of other parameters you can tag along, but this works (and I can receive it using netcat on another computer with: nc -u -l 192.168.0.255)
http://sourceforge.net/p/netcat/bugs/8/
Fortunately there is another software which can do this, although the commandline isn't quite as intuitive. socat handles all kinds of network (and unix socket) traffic. To do what you want to do in socat, try:Created: 2003-08-28
Network broadcast addresses do not work,
for UDP you need to set SO_BROADCAST option on sockets.
This is also a bug in original netcat.
echo "UDP broadcast" | socat - UDP4-DATAGRAM:192.168.0.255:11001,so-broadcast
which pipes "UDP broadcast" from echo (followed by \n) to socat, which has STDIN as input ("-"). Then outputs to UDP4-DATAGRAM on the broadcast address (192.168.0.255) with the "so-broadcast" flag. There are a bunch of other parameters you can tag along, but this works (and I can receive it using netcat on another computer with: nc -u -l 192.168.0.255)
- Super Jamie
- Posts: 310
- Joined: 2014/01/10 23:44:51
Re: netcat UDP broadcast
The US Navy's Multicast Dissemination Protocol is probably what you're looking for:
http://www.nrl.navy.mil/itd/ncs/products/mdp
http://www.nrl.navy.mil/itd/ncs/products/mdp