I'm doing application for iPhone using C sockets. At some point I'm performing recvfrom
on separate NSThread
(which is blocking) and I dont know how to force this operation to "unblock" and exit from thread gracefully. Calling shutdown()
or close()
doesn't change anything, recvfrom
still hangs. Is there any way to keep it as blocking socket and force it to close properly and exit from thread?
As I'm accused of not trying anything this is my piece of code which doesn't cause recvfrom
to "unblock":
This is what i have right now:
- (void) stopScan
{
NSLog(@"stopScan !!!");
[activityIndicator stopAnimating];
shutdown(broadcastSocket, SHUT_RDWR);
close(broadcastSocket);
[discoveryThread cancel];
[discoveryThread release];
discoveryThread = nil;
[scanTimer invalidate];
broadcastSocket = 0;
scanTimer = nil;
}
Calling just only shutdown()
or close()
does not unblock either.