예제 #1
0
        //way too many copies.  But for now we'll live with it.
        private StatusCode AskDnsServer(IPv4 dnsServer,
                                        byte[]    outData,
                                        out byte[] rcvData)
        {
            UDP udp = new UDP();

            udp.Bind(IPv4.Any, 0);
            udp.Connect(dnsServer, Dns.Format.ServerPort);

            Bytes packet = Bitter.FromByteArray(outData);

            udp.WriteData(packet);

            Bytes buffer;

            buffer = udp.PollReadData(TimeSpan.FromTicks(timeout.Ticks));

            //This is silly..I'll come back and clean this up.
            udp.Close();

            if (buffer == null)
            {
                rcvData = null;
                return(StatusCode.Timeout);
            }
            rcvData = new byte[buffer.Length];
            Bitter.ToByteArray(buffer, 0, buffer.Length, rcvData, 0);
            //delete buffer;

            return(StatusCode.Success);
        }
예제 #2
0
        public bool Start()
        {
            using (thisLock.Lock()) {
                if (udp != null)
                {
                    return(false);
                }
                udp = new UDP();
                udp.Bind(IPv4.Any, DhcpFormat.ClientPort);
                udp.Connect(IPv4.Broadcast, DhcpFormat.ServerPort);

                ResetAdapterIPInfo();

                workerDone   = false;
                workerThread = new Thread(this);
                workerThread.Start();
                return(true);
            }
        }