TCP/TCPConnection.m
changeset 46 50dc5502ef46
parent 33 a9c59b0acbbc
child 47 60f2b46d9a3b
     1.1 --- a/TCP/TCPConnection.m	Wed Apr 29 21:05:01 2009 -0700
     1.2 +++ b/TCP/TCPConnection.m	Sun May 10 19:05:52 2009 -0700
     1.3 @@ -75,10 +75,8 @@
     1.4      // +getStreamsToHost: is missing for some stupid reason on iPhone. Grrrrrrrrrr.
     1.5      CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)address.hostname, address.port,
     1.6                                         (CFReadStreamRef*)&input, (CFWriteStreamRef*)&output);
     1.7 -    if( input )
     1.8 -        [(id)CFMakeCollectable(input) autorelease];
     1.9 -    if( output )
    1.10 -        [(id)CFMakeCollectable(output) autorelease];
    1.11 +    if( input )  [NSMakeCollectable(input) autorelease];
    1.12 +    if( output ) [NSMakeCollectable(output) autorelease];
    1.13  #else
    1.14      [NSStream getStreamsToHost: [NSHost hostWithAddress: address.ipv4name]
    1.15                            port: address.port 
    1.16 @@ -120,17 +118,18 @@
    1.17      CFReadStreamRef readStream = NULL;
    1.18      CFWriteStreamRef writeStream = NULL;
    1.19      CFStreamCreatePairWithSocket(kCFAllocatorDefault, socket, &readStream, &writeStream);
    1.20 +	if( readStream )  [NSMakeCollectable(readStream) autorelease];
    1.21 +    if( writeStream ) [NSMakeCollectable(writeStream) autorelease];
    1.22 +	
    1.23      self = [self _initWithAddress: [IPAddress addressOfSocket: socket] 
    1.24 -                      inputStream: (NSInputStream*)CFMakeCollectable(readStream)
    1.25 -                     outputStream: (NSOutputStream*)CFMakeCollectable(writeStream)];
    1.26 +                      inputStream: (NSInputStream*)readStream
    1.27 +                     outputStream: (NSOutputStream*)writeStream];
    1.28      if( self ) {
    1.29          _isIncoming = YES;
    1.30          _server = [listener retain];
    1.31          CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
    1.32          CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
    1.33      }
    1.34 -    if(readStream) CFRelease(readStream);
    1.35 -    if(writeStream) CFRelease(writeStream);
    1.36      return self;
    1.37  }    
    1.38