NSInputStream and NSOutPutStream Status not changing from opening to open.

I'm trying to create Bonjour client and in the process trying to setup input and output streams, I've successfully created the bonjour client, detected them and resolved them. After resolving I'm trying to setup input and output streams but when I tried sending message they do not go. The stream delegates are not getting called either, when I check the stream status it is always 1 (i.e opening), but never changes to open. Here is what I'm doing to get streams:

     -(void)viewDidAppear:(BOOL)animated

     {

          [self.service getInputStream:&inputStream outputStream:&outputStream];

               if(inputStream && outputStream) {

                    [outputStream setDelegate:self];

                    [inputStream setDelegate:self];

                    [self scheduleInCurrentThread];

                    [inputStream open];

                    [outputStream open];

                    NSLog(@"%lu",(unsigned long)inputStream.streamStatus);

                     NSLog(@"got Streams");

               }

               else {

                    NSLog(@"failed to acquire streams");

               }

     }

#pragma mark - schedule in current thread

    
- (void)scheduleInCurrentThread

{

[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

}

P.S: No object is nill.

After resolving I'm trying to setup input and output streams…

Resolving the NSNetService? You don’t need to do that; you can call

-getInputStream:outputStream:
and it will resolve as part of the opening the streams.

Beyond that, I can’t see anything specifically wrong with your code. Try removing the resolve to see if that improves things. I’ve seen cases where your operations on the NSNetService can confuse the streams’s operations on the NSNetService and cause weird problems like this (the streams should make a copy of the NSNetService and use that internally but that’s not how things currently work (r. 9821932)).

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
NSInputStream and NSOutPutStream Status not changing from opening to open.
 
 
Q