TCP/TCPConnection.m
changeset 10 a2aeb9b04ecc
parent 7 5936db2c1987
child 15 f723174fbc24
     1.1 --- a/TCP/TCPConnection.m	Sun May 25 13:43:03 2008 -0700
     1.2 +++ b/TCP/TCPConnection.m	Sun Jun 01 14:04:22 2008 -0700
     1.3 @@ -14,6 +14,15 @@
     1.4  #import "ExceptionUtils.h"
     1.5  
     1.6  
     1.7 +#if TARGET_OS_IPHONE
     1.8 +// SecureTransport.h is missing on iPhone, with its SSL constants:
     1.9 +enum{
    1.10 +    errSSLClosedAbort 			= -9806,	/* connection closed via error */
    1.11 +};
    1.12 +#endif
    1.13 +
    1.14 +
    1.15 +
    1.16  NSString* const TCPErrorDomain = @"TCP";
    1.17  
    1.18  
    1.19 @@ -62,10 +71,20 @@
    1.20  {
    1.21      NSInputStream *input = nil;
    1.22      NSOutputStream *output = nil;
    1.23 +#if TARGET_OS_IPHONE
    1.24 +    // +getStreamsToHost: is missing for some stupid reason on iPhone. Grrrrrrrrrr.
    1.25 +    CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)address.hostname, address.port,
    1.26 +                                       (CFReadStreamRef*)&input, (CFWriteStreamRef*)&output);
    1.27 +    if( input )
    1.28 +        [(id)CFMakeCollectable(input) autorelease];
    1.29 +    if( output )
    1.30 +        [(id)CFMakeCollectable(output) autorelease];
    1.31 +#else
    1.32      [NSStream getStreamsToHost: [NSHost hostWithAddress: address.ipv4name]
    1.33                            port: address.port 
    1.34                     inputStream: &input 
    1.35                    outputStream: &output];
    1.36 +#endif
    1.37      return [self _initWithAddress: address inputStream: input outputStream: output];
    1.38      //FIX: Support localPort!
    1.39  }