TCPConnection Class Reference

#import <TCPConnection.h>

Inherits TCPEndpoint.

Inherited by BLIPConnection.

List of all members.


Detailed Description

A generic class that manages a TCP socket connection.

It creates a TCPReader and a TCPWriter to handle I/O. TCPConnection itself mostly deals with SSL setup and opening/closing the socket. (The SSL related methods are inherited from TCPEndpoint.)

Public Member Functions

(id) - initToAddress:
 Initializes a TCPConnection to the given IP address.
(id) - initToAddress:localPort:
 Initializes a TCPConnection to the given IP address, binding to a specific outgoing port number.
(id) - initToNetService:
 Initializes a TCPConnection to the given NSNetService's address and port.
(id) - initIncomingFromSocket:listener:
 Initializes a TCPConnection from an incoming TCP socket.
(void) - open
 Opens the connection.
(void) - close
 Closes the connection, after waiting for all in-progress messages to be sent or received.
(void) - closeWithTimeout:
 Closes the connection, like -close, but if it hasn't closed by the time the timeout expires, it will disconnect the socket.

Static Public Member Functions

(void) + closeAllWithTimeout:
 Closes all open TCPConnections.
(void) + waitTillAllClosed
 Blocks until all open TCPConnections close.

Properties

assign id< TCPConnectionDelegatedelegate
 The delegate object that will be called when the connection opens, closes or receives messages.
readonly NSArray * peerSSLCerts
 The certificate(s) of the connected peer, if this connection uses SSL.
readonly TCPConnectionStatus status
 Connection's current status.
 readonly
 The IP address of the other peer.
readonly TCPListenerserver
 The TCPListener that created this incoming connection, or nil.
readonly BOOL isIncoming
 Is this an incoming connection, received via a TCPListener?
readonly NSError * error
 The fatal error, if any, that caused the connection to fail to open or to disconnect unexpectedly.
readonly NSString * actualSecurityLevel
 The actual security level of this connection.


Member Function Documentation

- (id) initToAddress: (IPAddress*)  address  

Initializes a TCPConnection to the given IP address.

Afer configuring settings, you should call -open to begin the connection.

- (id) initToAddress: (IPAddress*)  address
localPort: (UInt16)  localPort 

Initializes a TCPConnection to the given IP address, binding to a specific outgoing port number.

(This is usually only necessary when attempting to tunnel through a NAT.)

- (id) initToNetService: (NSNetService*)  service  

Initializes a TCPConnection to the given NSNetService's address and port.

If the service's address cannot be resolved, nil is returned.

- (id) initIncomingFromSocket: (CFSocketNativeHandle)  socket
listener: (TCPListener*)  listener 

Initializes a TCPConnection from an incoming TCP socket.

You don't usually need to call this; TCPListener does it automatically.

- (void) open  

Opens the connection.

This happens asynchronously; wait for a delegate method to be called. You don't need to open incoming connections received via a TCPListener.

- (void) close  

Closes the connection, after waiting for all in-progress messages to be sent or received.

This happens asynchronously; wait for a delegate method to be called.

- (void) closeWithTimeout: (NSTimeInterval)  timeout  

Closes the connection, like -close, but if it hasn't closed by the time the timeout expires, it will disconnect the socket.

+ (void) closeAllWithTimeout: (NSTimeInterval)  timeout  

Closes all open TCPConnections.

+ (void) waitTillAllClosed  

Blocks until all open TCPConnections close.

You should call +closeAllWithTimeout: first.


Property Documentation

- (assign id<TCPConnectionDelegate>) delegate

The delegate object that will be called when the connection opens, closes or receives messages.

Reimplemented in BLIPConnection.

- (NSArray *) peerSSLCerts

The certificate(s) of the connected peer, if this connection uses SSL.

The items in the array are SecCertificateRefs; use the Keychain API to work with them.

- TCPConnection:

The IP address of the other peer.

- (NSError *) error

The fatal error, if any, that caused the connection to fail to open or to disconnect unexpectedly.

- (NSString *) actualSecurityLevel

The actual security level of this connection.

Value is nil or one of the security level constants from NSStream.h, such as NSStreamSocketSecurityLevelTLSv1.


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