예제 #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 void Stop()
        {
            using (thisLock.Lock()) {
                workerDone = true;
                workerDoneEvent.WaitOne();

                udp.Close();
                udp          = null;
                workerThread = null;

                CancelTimeouts();
                @state = null;
            }
            DebugPrint("DhcpClient.Stop()\n");
        }