TCPListener Class Reference

#import <TCPListener.h>

Inherits TCPEndpoint.

Inherited by BLIPListener.

List of all members.


Detailed Description

Generic TCP-based server that listens for incoming connections on a port.

For each incoming connection, it creates an instance of (a subclass of) the generic TCP client class TCPClient. The -connectionClass property lets you customize which subclass to use.

TCPListener supports SSL, Bonjour advertisements for the service, and automatic port renumbering if there are conflicts. (The SSL related methods are inherited from TCPEndpoint.)

You will almost always need to implement the TCPListenerDelegate protocol in your own code, and set an instance as the listener's delegate property, in order to be informed of important events such as incoming connections.

Public Member Functions

(id) - initWithPort:
 Initializes a new TCPListener that will listen on the given port when opened.
(BOOL) - open:
 Opens the server.
(BOOL) - open
 Opens the server, without returning a specific error code.
(void) - close
 Closes the server.

Properties

Class connectionClass
 The subclass of TCPConnection that will be instantiated.
assign id< TCPListenerDelegatedelegate
 Delegate object that will be called when interesting things happen to the listener -- most importantly, when a new incoming connection is accepted.
BOOL useIPv6
 Should the server listen for IPv6 connections (on the same port number)? Defaults to NO.
uint16_t port
 The port number to listen on.
BOOL pickAvailablePort
 Should the server pick a higher port number if the desired port is already in use? Defaults to NO.
readonly BOOL isOpen
 Is the server currently open?
copy NSString * bonjourServiceType
 The Bonjour service type to advertise.
copy NSString * bonjourServiceName
 The Bonjour service name to advertise.
copy NSDictionary * bonjourTXTRecord
 The dictionary form of the Bonjour TXT record: metadata about the service that can be browsed by peers.
readonly BOOL bonjourPublished
 Is this service currently published/advertised via Bonjour?
readonly NSInteger bonjourError
 Current error status of Bonjour service advertising.


Member Function Documentation

- (id) initWithPort: (UInt16)  port  

Initializes a new TCPListener that will listen on the given port when opened.

- (BOOL) open: (NSError **)  error  

Opens the server.

You must call this after configuring all desired properties (property changes are ignored while the server is open.)

- (BOOL) open  

Opens the server, without returning a specific error code.

(In case of error the delegate's -listener:failedToOpen: method will be called with the error code, anyway.)

- (void) close  

Closes the server.


Property Documentation

- (Class) connectionClass

The subclass of TCPConnection that will be instantiated.

- (assign id<TCPListenerDelegate>) delegate

Delegate object that will be called when interesting things happen to the listener -- most importantly, when a new incoming connection is accepted.

- (BOOL) useIPv6

Should the server listen for IPv6 connections (on the same port number)? Defaults to NO.

- (uint16_t) port

The port number to listen on.

If the pickAvailablePort property is enabled, this value may be updated after the server opens to reflect the actual port number being used.

- (BOOL) pickAvailablePort

Should the server pick a higher port number if the desired port is already in use? Defaults to NO.

If enabled, the port number will be incremented until a free port is found.

- (copy NSString*) bonjourServiceType

The Bonjour service type to advertise.

Defaults to nil; setting it implicitly enables Bonjour. The value should look like e.g. "_http._tcp."; for details, see the NSNetService documentation.

- (copy NSString*) bonjourServiceName

The Bonjour service name to advertise.

Defaults to nil, meaning that a default name will be automatically generated if Bonjour is enabled (by setting -bonjourServiceType).

- (NSDictionary *) bonjourTXTRecord

The dictionary form of the Bonjour TXT record: metadata about the service that can be browsed by peers.

Changes to this dictionary will be pushed in near-real-time to interested peers.

- (readonly NSInteger) bonjourError

Current error status of Bonjour service advertising.

See NSNetServicesError for error codes.


The documentation for this class was generated from the following files:
Generated on Tue May 27 22:56:33 2008 for MYNetwork:MooseyardNetworking by  doxygen 1.5.4