From 52cc5b84bdd910fe315c8a77dd8a9a5b0f6d0502 Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Sun, 16 Mar 2003 18:55:50 +0000 Subject: [PATCH] BY THE POWER OF HEADERDOC! --- ITInetSocket.h | 82 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 10 deletions(-) diff --git a/ITInetSocket.h b/ITInetSocket.h index edbfa64..2f25958 100755 --- a/ITInetSocket.h +++ b/ITInetSocket.h @@ -11,10 +11,30 @@ #import #import "ITByteStream.h" +/*! + * @header ITInetSocket + * @abstract Definitions for the ITInetSocket class + */ + +/*! + * @constant ITInetMaxConnections + * @abstract The maximum number of running ITInetSockets you can have. + * @discussion The socket will error during a connection request if you are over the maximum. + */ + enum { - ITInetMaxConnections = 36 + ITInetMaxConnections = 128 }; +/*! + * @enum ITInetSocketState + * @abstract Possible states of a socket + * @constant ITInetSocketConnecting The socket is negotiating a connection. + * @constant ITInetSocketListening The socket is a server socket. + * @constant ITInetSocketReading The socket is reading data from the other side. + * @constant ITInetSocketWriting The socket is sending data to the other side. + * @constant ITInetSocketDisconnected The socket does not have a connection. + */ typedef enum { ITInetSocketConnecting, ITInetSocketListening, @@ -23,34 +43,76 @@ typedef enum { ITInetSocketDisconnected } ITInetSocketState; +/*! + * @enum ITInetSocketError + * @abstract Possible error conditions of a socket + * @constant ITInetHostNotFound The host specified does not actually exist. + * @constant ITInetConnectionDropped The remote side dropped the connection. + * @constant ITInetCouldNotConnect The socket was unable to connect for some reason + */ typedef enum { ITInetHostNotFound, ITInetConnectionDropped, - ITInetCouldNotConnect, + ITInetCouldNotConnect } ITInetSocketError; -@protocol ITInetSocketOwner -- (void) dataRecieved:(in NSData*)data; -- (void) errorOccured:(ITInetSocketError)err during:(ITInetSocketState)state; -- (void) finishedConnecting; +@class ITInetSocket; + +/*! + * @protocol ITInetSocketDelegate + * @abstract Delegate methods for ITInetSocket + * @discussion ITInetSockets use these methods to communicate with their delegates + */ +@protocol ITInetSocketDelegate +/*! + * @method dataRecieved: + * @abstract Alerts the delegate of data. + * @discussion The delegate should check [sender readPipe] to get the data. + * @param sender The socket that the messages came from. + */ +- (void) dataRecieved:(ITInetSocket *)sender; +/*! + * @method errorOccured:during:onSocket: + * @abstract Alerts the delegate of an error condition. + * @discussion The delegate can try retryCondition. + * @param err The error class. + * @param state What the socket was doing when the error occured. + * @param sender The socket the error occured on. + */ +- (void) errorOccured:(ITInetSocketError)err during:(ITInetSocketState)state onSocket:(ITInetSocket*)sender; +/*! + * @method finishedConnecting: + * @abstract Alerts the delegate of a successful connection attempt. + * @discussion The delegate should send whatever initial data is required for the protocol (nickname for IRC, etc.) + * @param sender The socket that established the connection. + */ +- (void) finishedConnecting:(ITInetSocket *)sender; @end +/*! + * @class ITInetSocket + * @abstract An Internet socket class. + * @discussion ITInetSocket is an Internet socket class supporting IPv6 and Rendezvous. + */ @interface ITInetSocket : NSObject { @public int sockfd; int port; id delegate; - struct addrinfo *ai; + struct addrinfo *ai, *ai_cur; ITByteStream *readPipe, *writePipe; ITInetSocketState state; NSArray *sarr; } -+(void)startAutoconnectingToService:(NSString*)type delegate:(id)d; --(id) initWithFD:(int)fd delegate:(id)d; --(id) initWithDelegate:(id)d; ++(void)startAutoconnectingToService:(NSString*)type delegate:(id )d; +-(id) initWithFD:(int)fd delegate:(id )d; +-(id) initWithDelegate:(id )d; +-(id )delegate; -(void) connectToHost:(NSString*)host onPort:(short)port; -(void) connectToHost:(NSString*)host onNamedPort:(NSString*)port; -(void) connectWithSockaddrArray:(NSArray*)arr; -(ITInetSocketState) state; +-(void) retryConnection; +-(void) disconnect; @end -- 2.20.1