www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Datagram Networking Not Getting any Data?

reply Andrew Wiley <debio264 gmail.com> writes:
I'm trying to write a DHCP server. Yes, I'm reinventing the wheel, but... why
is another post.

The problem isn't the protocol or understanding how it works. The problem is
getting my program to receive DHCP requests, which are UDP packets sent to
255.255.255.255 to port 67. Attached is my main loop to receive packets. You
can see where I have basically removed all packet processing. It looks like it
should just print "Packet!" whenever a UDP packet arrives on port 67, but it
doesn't.
My highly scientific test here was to start the program and force my laptop to
get a new IP address. Wireshark monitoring on my laptop confirms that there are
request packets going to 255.255.255.255:67, but the program just sits there.
 What's going on?
May 03 2008
parent e-t172 <e-t172 akegroup.org> writes:
Andrew Wiley a écrit :
 The problem isn't the protocol or understanding how it works. The problem is
getting my program to receive DHCP requests, which are UDP packets sent to
255.255.255.255 to port 67. Attached is my main loop to receive packets. You
can see where I have basically removed all packet processing. It looks like it
should just print "Packet!" whenever a UDP packet arrives on port 67, but it
doesn't.
You need to set the SO_BROADCAST flag in the socket. Use Socket.setOption() to do this, with SocketOption.SO_BROADCAST.
May 04 2008