Questions tagged [nsnetservice]

The NSNetService class represents a network service, either one your application publishes or is a client of. Available in OS X v10.2 and later with Apple's Foundation framework.

The methods of NSNetService operate asynchronously so your application is not impacted by the speed of the network. All information about a service is returned to your application through the NSNetService object’s delegate. You must provide a delegate object to respond to messages and to handle errors appropriately.

NSNetService class and the NSNetServiceBrowser class use multicast DNS to convey information about network services to and from your application. The API of NSNetService provides a convenient way to publish the services offered by your application and to resolve the socket address for a service.

The types of services you access using NSNetService are the same types that you access directly using BSD sockets. HTTP and FTP are two services commonly provided by systems. (For a list of common services and the ports used by those services, see the file /etc/services.) Applications can also define their own custom services to provide specific data to clients.

Source: NSNetService class reference

Related tags:

112 questions
2
votes
1 answer

NSStream - The operation couldn’t be completed. Connection refused

I am trying to couple 2 devices with NSNetService - Device A publishes the service and Device B can browse it and establish a connection. Yesterday I noticed a pretty nasty issue though. First time I start the service on Device A and try to open…
yacana
  • 144
  • 2
  • 10
2
votes
0 answers

Client not discovering bonjour service

I have just started learning to design iphone apps and I am trying to set up a client server environment. As a starter I would like to first make sure that the service I publish is visible to the client. I have written server and client codes wit…
1
vote
1 answer

NSNetService's "stop" method not working

I'm using NSNetService to broadcast using Bonjour. But when I want to stop it I use [netService stop], where netService is my NSNetService. It just doesn't stops, it gets called, but doesn't stops. netServiceDidStop is not being called, so I guess…
pmerino
  • 5,900
  • 11
  • 57
  • 76
1
vote
1 answer

NSNetService - how do I find out if it's a mac or iOS device?

Is there a way for me to find out if a device located over NSNetService is an iPhone, iPad or a Mac? The only solution I can think of right now is to connect to all of the ones found and ping them, and have each of them set up to ping back with that…
Andrew
  • 15,935
  • 28
  • 121
  • 203
1
vote
1 answer

NSNetServices persists after stop method call?

I am doing a simple bonjour broadcast using NSNetServices. Everything is working great when I start and stop the bonjour sharing at application launch/quit. However if I turn off bonjour using the stop method call, my app still appears to be…
slycrel
  • 4,275
  • 2
  • 30
  • 30
1
vote
2 answers

Synchronous Bonjour resolution with NSNetService (why is it taking so long to return control from the runloop?)

I am trying to do a Bonjour resolution of a service name synchronously, so I am trying to figure out how to properly wait for the netServiceDidResolveAddress() call of NSNetService. My code looks like this: service = [[NSNetService alloc]…
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
1
vote
1 answer

NSNetService on WiFi instead of bluetooth

I have 2 iOS devices and an application which starts or connects to a NSNetService. When both devices have have bluetooth turned on the data stream will automatically be done over the bluetooth interface. I do not want that, i want both devices to…
Mats Stijlaart
  • 5,058
  • 7
  • 42
  • 58
1
vote
1 answer

Connecting to a server with NSNetService but failing- automatic socket disconnect?

NEW SIMPLER VERSION OF PROBLEM: I'm trying to connect to and communicate with a Bonjour device using an Objective-C client and I'm having trouble resolving the service (server). Originally I tried to do a more complicated example, but I found the…
nflacco
  • 4,972
  • 8
  • 45
  • 78
1
vote
2 answers

Not getting read data simultaneously GCDAsyncSocket

I have two service class here. One is Host service and another is Join service class. From the HostService I am publishing NetService. In the JoinService I am using NetServiceBrowser for getting published service. Then successfully connected to that…
1
vote
0 answers

Setting up communication between multiple iOS devices using NSNetServices class

I am able to set up communication between multiple devices using NSNetServices class but only when those all devices are on same wifi network. Is it possible to make all the devices communicate regardless of the network availability, means it…
Rocky
  • 137
  • 1
  • 11
1
vote
2 answers

Mac: How to see list of running network services?

I am writing an application that needs to connect with a running network service on a Mac. Problem is, I have no idea what the service is called or even what port it uses. Is there a way to browse all running network services on my Mac? More…
Jordan Smith
  • 10,310
  • 7
  • 68
  • 114
1
vote
1 answer

Swift 3 - Got an empty NetService.addresses array after exploring bonjour

I'm pretty new in Swift 3. I want to get the ip of my NetServices which I explored with bonjour to show them to the user, not to connect with the device. So far I can search for devices with bonjour and get them listed in a listView with this great…
Melf11
  • 41
  • 8
1
vote
0 answers

NSURLSession download speed

For my tvOS app I need to download a file at app startup which is around 500 Mb. With NSURLSession it's an easy task to download large files directly to disk. I'm able to download file pretty fast as per network profiler. Graph says I've got an…
1
vote
0 answers

NSNetServiceBrowser not able to find Apple TV "occasionally"

I am using NSNetServiceBrowser to find NSNetService of Apple TV over bonjour connection. Now my code works almost every time. But every once in a while (1 out of 10 times) NSNetServiceBrowser is not able to find NSNetService of Apple TV or taking…
blancos
  • 1,576
  • 2
  • 16
  • 38
1
vote
1 answer

Connect iPhone/iPad with Mac (the Apple way)

When Apple's Remote app tries to connect to a Mac (running iTunes) on a local network (using WiFi), the user needs to enter a passcode provided by the iPhone as a security measure. This approach has been adopted by a number of other apps (e.g.,…
Bart Jacobs
  • 9,022
  • 7
  • 47
  • 88