public Session(ClientPipe clientPipe, ServerPipe serverPipe)
        {
            this.Timers = new SessionTimers();
            this.Timers.ClientConnected = DateTime.Now;

            this.Flags = new StringDictionary();
            if (clientPipe != null)
            {
                this.clientIP = (clientPipe.Address == null) ? null : clientPipe.Address.ToString();
                this.clientPort = clientPipe.Port;
                this.Flags["x-clientIP"] = this.clientIP;
                this.Flags["x-clientport"] = this.clientPort.ToString();
                if (clientPipe.LocalProcessID != 0)
                {
                    this._localProcessID = clientPipe.LocalProcessID;
                    this.Flags["x-ProcessInfo"] = string.Format("{0}:{1}", clientPipe.LocalProcessName, this._localProcessID);
                    this._localProcessName = clientPipe.LocalProcessName;
                }
            }
            this.Response = new ServerChatter(this);
            this.Request = new ClientChatter(this);
            this.Request.ClientPipe = clientPipe;
            this.Response.ServerPipe = serverPipe;
        }
 public static IPAddress[] GetIPAddressList(string sRemoteHost, bool bCheckCache, SessionTimers oTimers)
 {
     IPAddress[] arrResult = null;
     DNSCacheEntry entry;
     Stopwatch stopwatch = Stopwatch.StartNew();
     IPAddress address = Utilities.IPFromString(sRemoteHost);
     if (address != null)
     {
         arrResult = new IPAddress[] { address };
         if (oTimers != null)
         {
             oTimers.DNSTime = (int) stopwatch.ElapsedMilliseconds;
         }
         return arrResult;
     }
     if (bCheckCache && dictAddresses.TryGetValue(sRemoteHost, out entry))
     {
         if (entry.iLastLookup > (Environment.TickCount - MSEC_DNS_CACHE_LIFETIME))
         {
             arrResult = entry.arrAddressList;
         }
         else
         {
             lock (dictAddresses)
             {
                 dictAddresses.Remove(sRemoteHost);
             }
         }
     }
     if (arrResult == null)
     {
         try
         {
             arrResult = Dns.GetHostAddresses(sRemoteHost);
         }
         catch
         {
             if (oTimers != null)
             {
                 oTimers.DNSTime = (int) stopwatch.ElapsedMilliseconds;
             }
             throw;
         }
         arrResult = trimAddressList(arrResult);
         if (arrResult.Length < 1)
         {
             throw new Exception("No valid IPv4 addresses were found for this host.");
         }
         if (arrResult.Length > 0)
         {
             lock (dictAddresses)
             {
                 if (!dictAddresses.ContainsKey(sRemoteHost))
                 {
                     dictAddresses.Add(sRemoteHost, new DNSCacheEntry(arrResult));
                 }
             }
         }
     }
     if (oTimers != null)
     {
         oTimers.DNSTime = (int) stopwatch.ElapsedMilliseconds;
     }
     return arrResult;
 }