• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: straight-C DNS lookup with timeout?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: straight-C DNS lookup with timeout?


  • Subject: Re: straight-C DNS lookup with timeout?
  • From: Kyle Moffett <email@hidden>
  • Date: Sun, 5 Jan 2003 15:47:14 -0500

On Monday, Dec 30, 2002, at 05:40 US/Eastern, David Rio Vierra wrote:

Yes, you can kill pthreads. From `man pthread`:

int pthread_cancel(pthread_t thread)
Cancels execution of a thread.

You acquire the pthread_t from:

int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void
*(*start_routine)(void *), void *arg)
Creates a new thread of execution.

- Rio

Best of all, NSThreads use pthreads internally! Unfortunately, they do other cocoa stuff too, so you will get retain release problems and stuff by killing it like that, no matter how you do it. I would recommend that you just detach thread, wait the specified time, then [doneLock lock]. If there is data stored, then use it, otherwise, just ignore the extra thread and [doneLock unlock]. The extra thread should [doneLock lock], set the data then set a BOOL to indicate that it found the data, then [doneLock unlock]. At that point it should either exit, or go do something else (Wait for another DNS request?).

HTH,
Kyle Moffett

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/IT/U d- s++:- a16 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$ L+++(++) E W++( +) N+++(++) o? K? w---(-) O? M++ V? PS+() PE+(-) Y+ PGP? t+(+++) 5 X R? tv-(--) b++++(++) Dl+ D+ G e->++++$ h! !r-- !y?
------END GEEK CODE BLOCK------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Prev by Date: Working with 32-bit Unicode (NSString stringWithUTF32String: (const UTF32Char *) bytes needed)
  • Next by Date: foundation kit (help i'm new to cocoa)
  • Previous by thread: Re: straight-C DNS lookup with timeout?
  • Next by thread: drawing custom button in cocoa
  • Index(es):
    • Date
    • Thread