Re: NSStream Operation Timed out issue
Re: NSStream Operation Timed out issue
- Subject: Re: NSStream Operation Timed out issue
- From: Ramesh P <email@hidden>
- Date: Fri, 20 Nov 2009 18:00:06 +0530
Hi Quinn..
Here is my code..
-(void)startSocket:(NSString *)url{
NSURL *website = [NSURL URLWithString:str];
NSHost *host = [NSHost hostWithName:[website host]];
if(host) {
[NSStream getStreamsToHost:host port:PORT inputStream:&iStream outputStream:&oStream] ;
[self openStream];
}
else
NSLog(@"InValid host");
}
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
here i am handling all the events.
}
-(void)openStream{
NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:1];
[settings setObject:(NSString *)NSStreamSocketSecurityLevelTLSv1 forKey:(NSString *)kCFStreamSSLLevel];
[settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
[settings setObject:@"
www.xyz.com" forKey:(NSString *)kCFStreamSSLPeerName];
[iStream retain];
[iStream setDelegate:self];
[iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
CFReadStreamSetProperty((CFReadStreamRef)iStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
[iStream open];
[oStream retain];
[oStream setDelegate:self];
[oStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
CFWriteStreamSetProperty((CFWriteStreamRef)oStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
[oStream open];
}
-(void)closeStream {
[iStream close];
[oStream close];
[iStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[oStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[iStream setDelegate:nil];
[oStream setDelegate:nil];
[iStream release];
[oStream release];
iStream=nil;
oStream=nil;
}
Thanks,
Ramesh.P
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden