Changeset 5396
- Timestamp:
- 03/14/08 17:17:18 (4 months ago)
- Files:
-
- WiredAdditions/trunk/WNSocket.h (modified) (2 diffs)
- WiredAdditions/trunk/WNSocket.m (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredAdditions/trunk/WNSocket.h
r5378 r5396 29 29 #import <openssl/ssl.h> 30 30 31 @interface WNSocket Context: WIObject {32 wi_socket_ context_t *_context;31 @interface WNSocketTLS : WIObject { 32 wi_socket_tls_t *_tls; 33 33 } 34 34 35 35 36 + (WNSocket Context *)socketContextForClient;36 + (WNSocketTLS *)socketTLSForClient; 37 37 38 38 - (void)setSSLCiphers:(NSString *)iphers; … … 97 97 - (BOOL)waitWithTimeout:(NSTimeInterval)timeout; 98 98 99 - (BOOL)connectWithContext:(WNSocketContext *)context timeout:(NSTimeInterval)timeout error:(WNError **)error; 99 - (BOOL)connectWithTimeout:(NSTimeInterval)timeout error:(WNError **)error; 100 - (BOOL)connectWithTLS:(WNSocketTLS *)tls timeout:(NSTimeInterval)timeout error:(WNError **)error; 100 101 - (void)close; 101 102 WiredAdditions/trunk/WNSocket.m
r5378 r5396 34 34 35 35 36 @interface WNSocket Context(Private)37 38 - (wi_socket_ context_t *)_context;36 @interface WNSocketTLS(Private) 37 38 - (wi_socket_tls_t *)_tls; 39 39 40 40 @end 41 41 42 42 43 @implementation WNSocket Context(Private)44 45 - (wi_socket_ context_t *)_context{46 return _ context;43 @implementation WNSocketTLS(Private) 44 45 - (wi_socket_tls_t *)_tls { 46 return _tls; 47 47 } 48 48 … … 50 50 51 51 52 @implementation WNSocket Context53 54 + (WNSocket Context *)socketContextForClient {55 WNSocket Context *context;56 57 context= [[self alloc] init];58 59 wi_socket_ context_set_ssl_type(context->_context, WI_SOCKET_SSL_CLIENT);60 61 return [ contextautorelease];52 @implementation WNSocketTLS 53 54 + (WNSocketTLS *)socketTLSForClient { 55 WNSocketTLS *tls; 56 57 tls = [[self alloc] init]; 58 59 wi_socket_tls_set_type(tls->_tls, WI_SOCKET_TLS_CLIENT); 60 61 return [tls autorelease]; 62 62 } 63 63 … … 70 70 71 71 pool = wi_pool_init(wi_pool_alloc()); 72 _ context = wi_socket_context_init(wi_socket_context_alloc());72 _tls = wi_socket_tls_init(wi_socket_tls_alloc()); 73 73 wi_release(pool); 74 74 … … 79 79 80 80 - (void)dealloc { 81 wi_release(_ context);81 wi_release(_tls); 82 82 83 83 [super dealloc]; … … 92 92 93 93 pool = wi_pool_init(wi_pool_alloc()); 94 wi_socket_ context_set_ssl_ciphers(_context, wi_string_with_cstring([ciphers UTF8String]));94 wi_socket_tls_set_ciphers(_tls, wi_string_with_cstring([ciphers UTF8String])); 95 95 wi_release(pool); 96 96 } … … 337 337 #pragma mark - 338 338 339 - (BOOL)connectWith Context:(WNSocketContext *)context timeout:(NSTimeInterval)timeout error:(WNError **)error {339 - (BOOL)connectWithTimeout:(NSTimeInterval)timeout error:(WNError **)error { 340 340 wi_pool_t *pool; 341 341 BOOL result = YES; … … 343 343 pool = wi_pool_init(wi_pool_alloc()); 344 344 345 wi_uuid(); 346 347 if(!wi_socket_connect(_socket, [context _context], timeout)) { 345 if(!wi_socket_connect(_socket, timeout)) { 346 if(error) { 347 *error = [WNError errorWithDomain:WNWiredNetworkingErrorDomain 348 code:WNSocketConnectFailed 349 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: 350 [WNError errorWithDomain:WNLibWiredErrorDomain], WNLibWiredErrorKey, 351 [_address string], WIArgumentErrorKey, 352 NULL]]; 353 } 354 355 result = NO; 356 } 357 358 wi_release(pool); 359 360 return result; 361 } 362 363 364 365 - (BOOL)connectWithTLS:(WNSocketTLS *)tls timeout:(NSTimeInterval)timeout error:(WNError **)error { 366 wi_pool_t *pool; 367 BOOL result = YES; 368 369 pool = wi_pool_init(wi_pool_alloc()); 370 371 if(!wi_socket_connect_tls(_socket, [tls _tls], timeout)) { 348 372 if(error) { 349 373 *error = [WNError errorWithDomain:WNWiredNetworkingErrorDomain
