Re: Bonjour server with multiple clients
Re: Bonjour server with multiple clients
- Subject: Re: Bonjour server with multiple clients
- From: Jim Correia <email@hidden>
- Date: Mon, 12 Jan 2009 14:42:08 -0500
On Jan 12, 2009, at 1:13 PM, Kyle Sluder wrote:
On Mon, Jan 12, 2009 at 12:32 PM, Dave DeLong <email@hidden>
wrote:
The NSNetService publishes on a port and the server creates an
NSFileHandle
(fh1) for the NSNetService to begin listening to connection
attempts. This
fileHandle is listening on the same port on which the netService was
published.
NSNetService has nothing whatsoever to do with the actual connection.
The server creates the socket/NSFileHandle to listen to connections,
then provides that info to the NSNetService which publishes that info
over Bonjour.
To give an extreme example which hopefully clears this up once and for
all...
Suppose Kyle wrote a server using MagicServerKit, that listened (for
multiple connections) on a port specified in his config file.
But he doesn't support Bonjour, so clients on the network need to know
both the IP# and port of the machine they are connecting to.
I can, using NSNetService, write an application, running in a
completely separate process, that reads his config file and advertises
his service via Bonjour. Clients can use this information to connect
to his service. How he implemented this service is a completely
separate concern.
On Jan 12, 2009, at 12:32 PM, Dave DeLong wrote:
(This is where things start getting fuzzy)
The server, meanwhile, is notified that someone is trying to hook up
to fh1, and gets a new fileHandle via the notification object sent
along in the NSFileHandleConnectionAcceptedNotification.
The documentation for -acceptConnectionInBackgroundAndNotify describes
what happens. A new file handle for reading and writing to the other
end of the connection is created and passed to you via the
notification. If you want to accept additional connections, you send -
acceptConnectionInBackgroundAndNotify to the original file handle again.
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileHandle_Class/Reference/Reference.html#/
/apple_ref/occ/instm/NSFileHandle/acceptConnectionInBackgroundAndNotify
<repeating-myself>
The Picture Sharing sample shows an example of how this works if you
wish to try to write a server using the same techniques.
</repeating-myself>
Jim
_______________________________________________
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