Re: Threading problem using AsyncSocket (Matthew Youney)
Re: Threading problem using AsyncSocket (Matthew Youney)
- Subject: Re: Threading problem using AsyncSocket (Matthew Youney)
- From: "email@hidden" <email@hidden>
- Date: Thu, 14 Aug 2008 22:03:45 +0100
I don't know about your threading problem but surely the whole point
of AsyncSocket is the Async bit.
It is designed to attach itself to the runloop and remove the need for
blocking sockets etc on threads.
I use AsyncSocket extensively within the main thread and it can handle
multiple connection without any problem.
Hello list,
This is my first attempt at threading with Cocoa, and I am having
difficu=
lty
with my classes that use AsyncSocket. I am using
DetachNewThreadSelector=
:
to detach my =91worker=92 thread, and I am instantiating my class
that us=
es
AsyncSocket from within this thread. The problem is that the
AsyncSocket
delegates are never called. This class works just fine from the main
thread.
- (IBAction)RunTestButtonPressed:(id)sender
{
[NSThread detachNewThreadSelector:
@selector(threadFunction:)
toTarget: self withObject: recipe];
}
- (void) threadFunction:(BeverageRecipe*)recipe
{
ClassContainingAsyncSocket* foo;
int i=3D0;
while (stuffTodo)
{
NSAutoreleasePool* autoReleasePool=3D[[NSAutoreleasePool alloc]init];
foo=3D[[ ClassContainingAsyncSocket alloc]init];
i=3D[foo readRegister:0]; //none of the AsyncSocket
delegate=
s
=91fire!=92
[autoReleasePool release];
do more stuff=85.
}
}
Does anyone have any idea what I am missing? Something fundamentally
wro=
ng?
Thanks in advance for any and all assistance.
Matt
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden