1.1 --- a/TCP/TCPStream.m Sat May 24 17:25:06 2008 -0700
1.2 +++ b/TCP/TCPStream.m Tue Jun 10 16:14:20 2008 -0700
1.3 @@ -8,6 +8,7 @@
1.4
1.5 #import "TCPStream.h"
1.6 #import "TCP_Internal.h"
1.7 +#import "IPAddress.h"
1.8
1.9 #import "Logging.h"
1.10 #import "Test.h"
1.11 @@ -46,11 +47,20 @@
1.12
1.13 - (id) propertyForKey: (CFStringRef)cfStreamProperty
1.14 {
1.15 - return nil; // abstract -- overridden by TCPReader and TCPWriter
1.16 + return [_stream propertyForKey: (NSString*)cfStreamProperty];
1.17 }
1.18
1.19 - (void) setProperty: (id)value forKey: (CFStringRef)cfStreamProperty
1.20 -{ // abstract -- overridden by TCPReader and TCPWriter
1.21 +{
1.22 + if( ! [_stream setProperty: value forKey: (NSString*)cfStreamProperty] )
1.23 + Warn(@"Failed to set property %@ on %@",cfStreamProperty,self);
1.24 +}
1.25 +
1.26 +
1.27 +- (IPAddress*) peerAddress
1.28 +{
1.29 + const CFSocketNativeHandle *socketPtr = [[self propertyForKey: kCFStreamPropertySocketNativeHandle] bytes];
1.30 + return socketPtr ?[IPAddress addressOfSocket: *socketPtr] :nil;
1.31 }
1.32
1.33
1.34 @@ -225,20 +235,6 @@
1.35 return _conn.writer;
1.36 }
1.37
1.38 -
1.39 -- (id) propertyForKey: (CFStringRef)cfStreamProperty
1.40 -{
1.41 - CFTypeRef value = CFReadStreamCopyProperty((CFReadStreamRef)_stream,cfStreamProperty);
1.42 - return [(id)CFMakeCollectable(value) autorelease];
1.43 -}
1.44 -
1.45 -- (void) setProperty: (id)value forKey: (CFStringRef)cfStreamProperty
1.46 -{
1.47 - if( ! CFReadStreamSetProperty((CFReadStreamRef)_stream,cfStreamProperty,(CFTypeRef)value) )
1.48 - Warn(@"%@ didn't accept property '%@'", self,cfStreamProperty);
1.49 -}
1.50 -
1.51 -
1.52 - (NSInteger) read: (void*)dst maxLength: (NSUInteger)maxLength
1.53 {
1.54 NSInteger bytesRead = [(NSInputStream*)_stream read:dst maxLength: maxLength];