@@ -86,10 +86,11 @@ id target; SEL selector; #ifdef OF_HAVE_BLOCKS of_tcpsocket_async_connect_block_t connectBlock; #endif + OFException *exception; } - initWithSourceThread: (OFThread*)sourceThread socket: (OFTCPSocket*)socket host: (OFString*)host @@ -161,10 +162,11 @@ [host release]; [target release]; #ifdef OF_HAVE_BLOCKS [connectBlock release]; #endif + [exception release]; [super dealloc]; } - (void)didConnect @@ -171,29 +173,33 @@ { [self join]; #ifdef OF_HAVE_BLOCKS if (connectBlock != NULL) - connectBlock(sock); + connectBlock(sock, exception); else { #endif - void (*func)(id, SEL, OFTCPSocket*) = - (void(*)(id, SEL, OFTCPSocket*))[target + void (*func)(id, SEL, OFTCPSocket*, OFException*) = + (void(*)(id, SEL, OFTCPSocket*, OFException*))[target methodForSelector: selector]; - func(target, selector, sock); + func(target, selector, sock, exception); #ifdef OF_HAVE_BLOCKS } #endif } - (id)main { void *pool = objc_autoreleasePoolPush(); - [sock connectToHost: host - port: port]; + @try { + [sock connectToHost: host + port: port]; + } @catch (OFException *e) { + exception = [[e retain] autorelease]; + } [self performSelector: @selector(didConnect) onThread: sourceThread waitUntilDone: NO];