www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - broadcasting using std.socket

reply Dominik Taborsky <bremby seznam.cz> writes:
Hi,

how do I broadcast a UDP packet?
I set the BROADCAST option on the socket (do I really have to) and then use the
address x.y.z.255 to broadcast it. The IP address is correctly set. I use it
this way:
socket_instance.sendTo(char[] packet, new InternetAddress(addr, port));

It returns -1 bytes sent, which I consider as an error. What am I missing?

Thanks in advance, Dominik
Dec 12 2009
parent Dominik Taborsky <bremby seznam.cz> writes:
Sorry for wasting space - I am an idiot. I created a TCP socket and I was
expecting a UDP packet to be sent. I just forgot about what I wrote before...
:-/



Dominik Taborsky Wrote:

 Hi,
 
 how do I broadcast a UDP packet?
 I set the BROADCAST option on the socket (do I really have to) and then use
the address x.y.z.255 to broadcast it. The IP address is correctly set. I use
it this way:
 socket_instance.sendTo(char[] packet, new InternetAddress(addr, port));
 
 It returns -1 bytes sent, which I consider as an error. What am I missing?
 
 Thanks in advance, Dominik
Dec 12 2009