Some mre debugging stuff, should be removed before rele
[ITFoundation.git] / ITInetSocket.h
index 367c31e..bcf30f5 100755 (executable)
@@ -7,10 +7,47 @@
 //
 
 #import <Foundation/Foundation.h>
+#import <netinet/in.h>
+#import <netdb.h>
 
+enum {
+    ITInetMaxConnections = 36
+};
 
-@interface ITInetSocket : NSObject {
+typedef enum {
+    ITInetSocketConnecting,
+    ITInetSocketListening,
+    ITInetSocketReading,
+    ITInetSocketWriting,
+    ITInetSocketDisconnected
+} ITInetSocketState;
+
+typedef enum {
+    ITInetHostNotFound,
+    ITInetConnectionDropped,
+    ITInetCouldNotConnect,
+} ITInetSocketError;
+
+@protocol ITInetSocketOwner
+- (void) dataRecieved:(in NSData*)data;
+- (void) errorOccured:(int)err during:(ITInetSocketState)state;
+- (void) finishedConnecting;
+@end
 
+@interface ITInetSocket : NSObject {
+    @public
+    int sockfd;
+    int port;
+    id delegate;
+    struct addrinfo *ai;
+    NSData *writeBuffer;
+    ITInetSocketState state;
 }
--(id)initWithFD:(int)fd delegate:(id)d;
+// Init
+-(id) initWithFD:(int)fd delegate:(id)d;
+-(id) initWithDelegate:(id)d;
+
+-(void) connectToHost:(NSString*)host onPort:(short)port;
+-(ITInetSocketState) state;
+
 @end