I want to test for the presence of DHCP in Air. This shouldn't be hard because this is a one packet request to the DHCP server. Basicall you fill out a 300 or so byte datagram with mostly zeroes, and then send it to IP 255.255.255.255 on port 67 and listen on port 68. My question is what is the basic operation of the use of UDP sockets. I tried the following just to see if anything would work, but my BIND operation failed. Not sure how to set up the destination and source addresses properly:
// open a datagram socket
var datagramSocket:DatagramSocket = new DatagramSocket();
//Bind the socket to the local network interface and port
trace("Bound to: " + datagramSocket.localAddress + ":" + datagramSocket.localPort);
// send the DHCPDiscovery packet to IP 255.255.255.255 port 67
//Listen for incoming datagrams
I am obviously doing something very wrong, as the BIND command fails with an error, no matter whether I bind to 255.255.255.255 or 0.0.0.0, not sure how do this kind of socket programming, but gosh this DHCP is about the simplest darn UDP thing I could imagine. Sure wish adobe would document the TIMING of calls that have to be made, like step 1 create the socket, step 2 add listener, step 3 bind.... etc. merely documenting what an API does DOES NOT INDICATE the all-critical sequence that must be observed, and I find this a consistent failure in documentation to even mention the commonly used sequences.
any help is greatly appreciated, a free copy of Discus labeling software to whoever helps me get this DHCP thing working, I just want to tell if DHCP is running on not on a host machine and give the user a simple graphic of thumbs up/down so my non-technical users can run this before they try using some equipment that happens to need DHCP. A bunch of non-technical users have installed hubs and switches instead of routers and of course without DHCP things get nasty fast.