My first question is how do I get the didAcceptConnectionWithInputStream:outputStream:
callback in NSNetServiceDelegate
to get called?
Follow up question: can I still establish a connection between a client and server, although I never get a callback saying that a connection was accepted (via didAcceptConnectionWithInputStream:outputStream:
)?
I understand that calling publishWithOptions
, while passing in the NSNetServiceListenForConnections
option is supposed to result in the NetServiceDelegate
callback (didAcceptConnectionWithInputStream:outputStream:
) to be called. However, that callback is not getting called.
Here are the steps I am taking, to publish:
Create
NSNetService
withself.netService = [[NSNetService alloc] initWithDomain:@"" type:_serviceType name:(_name == nil) ? @"" : _name port:0];
Schedule service in current runloop, in default mode
- Set the delegate to my Server wrapper object
- call
publishWithOptions:NSNetServiceListenForConnections
Here are the steps I take, to browse services:
- Create an
NSNetServiceBrowser
, and set its delegate to my client wrapper object - Call
searchForServicesOfType
for the same service type and domain asNSNetService
- List services in a
UITableView
for the UI, to allow a user to select a service - When a user selects a service, set the service's delegate to my client object, and call
getInputStream:outputSteam:
on the service - After getInputStream:outputSteam: returns success, I would expect
didAcceptConnectionWithInputStream:outputStream:
to get called. However this does not occur.
Thanks for your help!