TCP/TCPConnection.m
changeset 15 f723174fbc24
parent 8 6f539dd9921c
child 16 6f608b552b77
     1.1 --- a/TCP/TCPConnection.m	Thu May 29 16:40:36 2008 -0700
     1.2 +++ b/TCP/TCPConnection.m	Tue Jun 10 16:14:20 2008 -0700
     1.3 @@ -255,8 +255,12 @@
     1.4  {
     1.5      if( _status != kTCP_Closed && _status != kTCP_Disconnected ) {
     1.6          LogTo(TCP,@"%@ is now closed",self);
     1.7 -        self.status = (_status==kTCP_Closing ?kTCP_Closed :kTCP_Disconnected);
     1.8 -        [self tellDelegate: @selector(connectionDidClose:) withObject: nil];
     1.9 +        TCPConnectionStatus prevStatus = _status;
    1.10 +        self.status = (prevStatus==kTCP_Closing ?kTCP_Closed :kTCP_Disconnected);
    1.11 +        if( prevStatus==kTCP_Opening )
    1.12 +            [self tellDelegate: @selector(connection:failedToOpen:) withObject: self.error];
    1.13 +        else
    1.14 +            [self tellDelegate: @selector(connectionDidClose:) withObject: nil];
    1.15      }
    1.16      [NSObject cancelPreviousPerformRequestsWithTarget: self
    1.17                                               selector: @selector(_closeTimeoutExpired)