Hi all,
I've a problem with NSInputStream:
In my object I create (only once) an input and output stream like:
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault,
(CFStringRef)IPString, 2101, &readStream, &writeStream);
if (readStream==NULL || writeStream==NULL ) {
return NO;
}
CFReadStreamSetProperty(readStream,
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
CFWriteStreamSetProperty(writeStream,
kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
serialInput=(NSInputStream *)readStream;
serialOutput=(NSOutputStream *)writeStream;
[serialInput setDelegate:self];
[serialOutput setDelegate:self];
[serialInput scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[serialOutput scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSDefaultRunLoopMode];
[serialOutput open];
[serialInput open];
When I'm done with my object, I clean it up (in dealloc) like:
[serialInput close];
[serialInput release];
[serialOutput close];
[serialOutput release];
The problem is now that the stream event handler is still called after dealloc
has finished, resulting in a crash. How can I make sure that the event handler
is not called anymore? It seems the socket does not get properly closed. Maybe
a problem with slow handshaking over Wi-Fi?
Any help is appreciated.
Kind regards,
Remco Poelstra
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]