diff -r 6f539dd9921c -r f723174fbc24 TCP/TCPConnection.m --- a/TCP/TCPConnection.m Thu May 29 16:40:36 2008 -0700 +++ b/TCP/TCPConnection.m Tue Jun 10 16:14:20 2008 -0700 @@ -255,8 +255,12 @@ { if( _status != kTCP_Closed && _status != kTCP_Disconnected ) { LogTo(TCP,@"%@ is now closed",self); - self.status = (_status==kTCP_Closing ?kTCP_Closed :kTCP_Disconnected); - [self tellDelegate: @selector(connectionDidClose:) withObject: nil]; + TCPConnectionStatus prevStatus = _status; + self.status = (prevStatus==kTCP_Closing ?kTCP_Closed :kTCP_Disconnected); + if( prevStatus==kTCP_Opening ) + [self tellDelegate: @selector(connection:failedToOpen:) withObject: self.error]; + else + [self tellDelegate: @selector(connectionDidClose:) withObject: nil]; } [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector(_closeTimeoutExpired)