00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #import "ONSocket.h"
00011 #import "ONInterface.h"
00012 #import <pthread.h>
00013
00014 @class ONHost;
00015 @class ONHostAddress;
00016 @class ONPortAddress;
00017 @class ONServiceEntry;
00018
00019 #import <Foundation/NSDate.h>
00020
00021 @interface ONInternetSocket : ONSocket
00022 {
00023
00024 int socketFD;
00025
00026
00027 pthread_mutex_t socketLock;
00028
00029
00030 short socketPF;
00031
00032
00033 ONPortAddress *localAddress;
00034 ONPortAddress *remoteAddress;
00035 ONHost *remoteHost;
00036
00037 struct {
00038 unsigned int listening:1;
00039 unsigned int connected:1;
00040 unsigned int userAbort:1;
00041 unsigned int shouldNotCloseFD:1;
00042
00043
00044 unsigned int nonBlocking:1;
00045 unsigned int allowAddressReuse:1;
00046 unsigned int allowBroadcast:1;
00047 } flags;
00048
00049 int requestedLocalPort;
00050 }
00051
00052 + (int)socketType;
00053 + (int)ipProtocol;
00054
00055 + (ONInternetSocket *)socket;
00056
00057 + (ONInternetSocket *)socketWithConnectedFileDescriptor:(int)fd shouldClose:(BOOL)closeOnDealloc;
00058
00059 - (void)setLocalPortNumber;
00060
00061
00062 - (void)setLocalPortNumber:(int)port;
00063
00064
00065 - (void)setLocalPortNumber:(int)port allowingAddressReuse:(BOOL)reuse;
00066
00067
00068 - (int)addressFamily;
00069
00070 - (void)setAddressFamily:(int)newAddressFamily;
00071
00072
00073 - (ONPortAddress *)localAddress;
00074 - (unsigned short int)localAddressPort;
00075
00076 - (ONHost *)remoteAddressHost;
00077 - (ONPortAddress *)remoteAddress;
00078 - (unsigned short int)remoteAddressPort;
00079
00080 - (ONInterface *)localInterface;
00081
00082 - (void)connectToPortAddress:(ONPortAddress *)portAddress;
00083 - (void)connectToHost:(ONHost *)host serviceEntry:(ONServiceEntry *)service;
00084 - (void)connectToHost:(ONHost *)host port:(unsigned short int)port;
00085 - (void)connectToAddress:(ONHostAddress *)hostAddress port:(unsigned short int)port;
00086 - (void)connectToAddressFromArray:(NSArray *)portAddresses;
00087
00088
00089 - (void)setNonBlocking:(BOOL)shouldBeNonBlocking;
00090 - (BOOL)waitForInputWithTimeout:(NSTimeInterval)timeout;
00091
00092 - (void)setAllowsBroadcast:(BOOL)shouldAllowBroadcast;
00093
00094
00095 - (int)socketFD;
00096
00097 - (BOOL)isConnected;
00098 - (BOOL)didAbort;
00099
00100 @end
00101
00102
00103 static inline int ONProtocolFamilyForAddressFamily(int addressFamily)
00104 {
00105 return addressFamily;
00106 }
00107
00108 static inline int ONAddressFamilyForProtocolFamily(int protocolFamily)
00109 {
00110 return protocolFamily;
00111 }
00112
00113
00114 #import "FrameworkDefines.h"
00115
00116
00117 OmniNetworking_EXTERN NSString *ONInternetSocketBindFailedExceptionName;
00118 OmniNetworking_EXTERN NSString *ONInternetSocketReuseSelectionFailedExceptionName;
00119 OmniNetworking_EXTERN NSString *ONInternetSocketBroadcastSelectionFailedExceptionName;
00120 OmniNetworking_EXTERN NSString *ONInternetSocketConnectFailedExceptionName;
00121 OmniNetworking_EXTERN NSString *ONInternetSocketConnectTemporarilyFailedExceptionName;
00122 OmniNetworking_EXTERN NSString *ONInternetSocketGetNameFailedExceptionName;
00123 OmniNetworking_EXTERN NSString *ONInternetSocketNotConnectedExceptionName;
00124 OmniNetworking_EXTERN NSString *ONInternetSocketReadFailedExceptionName;
00125 OmniNetworking_EXTERN NSString *ONInternetSocketSetOptionFailedExceptionName;
00126 OmniNetworking_EXTERN NSString *ONInternetSocketUserAbortExceptionName;
00127 OmniNetworking_EXTERN NSString *ONInternetSocketWriteFailedExceptionName;
00128 OmniNetworking_EXTERN NSString *ONInternetSocketCloseFailedExceptionName;