• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bonjour server with multiple clients
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bonjour server with multiple clients


  • Subject: Re: Bonjour server with multiple clients
  • From: Markus Spoettl <email@hidden>
  • Date: Fri, 9 Jan 2009 17:57:28 -0800

On Jan 9, 2009, at 5:38 PM, Kyle Sluder wrote:
The first thing you see when you open up PicSharingController.m in
that example is the following:

-----
- (IBAction)toggleSharing:(id)sender {

   uint16_t chosenPort;
   if(!listeningSocket) {

       // Here, create the socket from traditional BSD socket calls,
and then set up an NSFileHandle with
       //that to listen for incoming connections.
-----

So the actual communication between clients has nothing to do with
Bonjour.  Bonjour just advertises to other machines "hey I'm listening
for picture sharing on this socket!"  As Jim said, the notion of a
"Bonjour connection" is flawed because of how the protocol works.


Of course that's all true but you will also notice that in fact you have to provide a port for NSNetService that you get via a sequence of calls that produce your listeningSocket further down the same method:

----
   chosenPort = ntohs(serverAddress.sin_port);
----

----
listeningSocket = [[NSFileHandle alloc] initWithFileDescriptor:fdForListening closeOnDealloc:YES];
----


and

----
netService = [[NSNetService alloc] initWithDomain:@"" type:@"_wwdcpic._tcp." name:[serviceNameField stringValue] port:chosenPort];
----


You need to create the listeningSocket to read data, the port alone will not help you (in that example).

I don't argue with that with the terminology issues but: The real question the OP had (I think) was not addressed. And I'd like to know it too:

How does one go about advertising a service via bonjour like in the Picture Sharing example AND allow multiple connections instead of just one? Is it as simple as creating multiple listeningSockets? Or create a new listening socket each time you get a connection to the existing one?

Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Bonjour server with multiple clients
      • From: Jim Correia <email@hidden>
    • Re: Bonjour server with multiple clients
      • From: Andrew Farmer <email@hidden>
References: 
 >Bonjour server with multiple clients (From: Dave DeLong <email@hidden>)
 >Re: Bonjour server with multiple clients (From: Jim Correia <email@hidden>)
 >Re: Bonjour server with multiple clients (From: Markus Spoettl <email@hidden>)
 >Re: Bonjour server with multiple clients (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: A Question on estimating +arrayWithCapacity
  • Next by Date: Re: Bonjour server with multiple clients
  • Previous by thread: Re: Bonjour server with multiple clients
  • Next by thread: Re: Bonjour server with multiple clients
  • Index(es):
    • Date
    • Thread