CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Location
    Punjab, India
    Posts
    113

    blocking function

    hi, i am using dnsquery api function to query the mx record, what it seems to me as blocking my application. Is there any alternative or solution.

  2. #2
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    I did just look through the DNS API and I couldn't see any support for asynchronous calls or setting a timeout.

    I would start thread and call it from the thread. Then you can implement your own timeout by using WaitForSingleObject on the thread handle (from the calling thread).

  3. #3
    Join Date
    Jan 2004
    Location
    Punjab, India
    Posts
    113
    Can you provide some sample code please how timeout can be implemented as after a particular period i have to kill the thread assuming that my DNS query failed.
    I can't use terminate thread as it may induce resource leakage. And as call to api is blocking, how can i use WaitForSingleObject, please elaborate a bit.

  4. #4
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    Sure, download attached ZIP file.
    Attached Files Attached Files

  5. #5
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    Hmm... There is a small design error in the attached code in my previous post. I don't know if this error will show up (it never did for me), but the correction is to let the thread release parameters upon timeout. This is of course a bit tricky, becuase the thead must then know about the timeout (that it happened).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured