DTBonjourDataConnection Class Reference
| Inherits from | NSObject | 
| Declared in | DTBonjourDataConnection.h | 
Overview
This class represents a data connection, established via file handle or Bonjour NSNetService
It can be used by itself to establish a connection as a client to a remote server. In the context of a DTBonjourServer there might be any number of live connections. In the server context you should not modify the connection delegate as the connections are owned and maintained by the server.
Tasks
Creating a Data Connection
Connection Lifetime
Sending Objects
Getting Information
- 
	
		
– isOpen - 
	
		
delegateproperty - 
	
		
sendingContentTypeproperty 
Properties
delegate
A delegate to be informed about activities of the connection. If the connection is owned by a DTBonjourServer you should not modify this property.
@property (nonatomic, weak) id<DTBonjourDataConnectionDelegate> delegateDeclared In
DTBonjourDataConnection.hsendingContentType
The type of how objects are to be encoded for transit. The default is to encode with NSCoding, JSON is also available as an option.
@property (nonatomic, assign) DTBonjourDataConnectionContentType sendingContentTypeDiscussion
Note: JSON can only encode NSArray and NSDictionary root objects.
Declared In
DTBonjourDataConnection.hInstance Methods
initWithInputStream:outputStream:
Initializes the receiver from the given input and output streams.
- (id)initWithInputStream:(NSInputStream *)inStream outputStream:(NSOutputStream *)outStreamParameters
- inStream
 Input stream for the connection.
- outStream
 Output stream for the connection.
Declared In
DTBonjourDataConnection.hinitWithNativeSocketHandle:
Initializes the receiver from a native Posix file handle representing a socket.
- (id)initWithNativeSocketHandle:(CFSocketNativeHandle)nativeSocketHandleParameters
- nativeSocketHandle
 The native socket handle to create the connection for
Declared In
DTBonjourDataConnection.hinitWithService:
Initialized the receiver from a Bonjour NSNetService
- (id)initWithService:(NSNetService *)serviceParameters
- service
 The
NSNetServiceto create the connection for
Declared In
DTBonjourDataConnection.hisOpen
YES if the connection is open and can be used to send or receive data
- (BOOL)isOpenReturn Value
YES if the connection is open and can be used to send or receive data
Declared In
DTBonjourDataConnection.hopen
Opens the connection and establishes the input and output streams. Cancels the
opening after a timeout of DTBonjourDataConnectionDefaultTimeout seconds.
- (BOOL)openReturn Value
YES if the connection could be established.
Declared In
DTBonjourDataConnection.hopenWithTimeout:
Opens the connection and establishes the input and output streams.
- (BOOL)openWithTimeout:(NSTimeInterval)timeoutParameters
- timeout
 Timeout in seconds after which to cancel the stream opening.
Return Value
YES if the connection could be established.
Declared In
DTBonjourDataConnection.hsendObject:error:
Encodes the passed object via the current sendingContentType and adds it to the output stream.
- (BOOL)sendObject:(id)object error:(NSError **)errorParameters
- object
 Can be any object that is supported by the current sending content type.
- error
 An option error output parameter
Return Value
YES if the object was successfully encoded and enqueued for sending
Discussion
Note: The return parameter does not tell if the actual sending has already taken place, only if the object could be encoded and enqueued for sending.
Declared In
DTBonjourDataConnection.h