< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Stun Delay Problem


Hi everyone

      this is my code for getting stun address

resip::Tuple Util::GetStunAddres(resip::UdpTransport *udp_p)
{
      DebugLog(<<"Crossbow::Entered into GetStunAddress");
      resip::Tuple mMappedAddress;
    mMappedAddress.setPort(0);
      string IpAddress="";
    if (!udp_p) return mMappedAddress;
    if (!udp_p->stunResult(mMappedAddress))
    {
         // no valid result available, send another request
         SendStunTest(udp_p);
    }

    else if ((GetTickCount() - mLastStunTestTime) > 1000 * 60 * 3)
    {
         // don't use a STUN response that is older than 3 minutes
         SendStunTest(udp_p);
    }

    DWORD dwTmpLastStunTestTime = mLastStunTestTime;

    while ((GetTickCount() - dwTmpLastStunTestTime) < 5 * 1000)
    {
             Sleep(12000);
         if (udp_p->stunResult(mMappedAddress))
            IpAddress=resip::Tuple::inet_ntop(mMappedAddress).c_str();
            DebugLog(<<"Crossbow::Stun Mapped Address is "<<IpAddress);
            break;
         Sleep(15000);
      }

      IpAddress=resip::Tuple::inet_ntop(mMappedAddress).c_str();
      DebugLog(<<"Crossbow::Stun Mapped Address is "<<IpAddress);
      return mMappedAddress;

}

This code works fine.But if i put first Sleep as Sleep(100) and second
Sleep as Sleep(200) in While Loop then my Ipaddress string contains 0.0.0.0
although request goes to STUN Server . I  want to minimize this delay.
So What is the most appropriate way to minimize this delay and get a mapped
address correctly?
Thanks in Advance
Gurpreet Singh Sidhu

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you