@@ -72,10 +72,11 @@ OFTCPSocket *_socket; OFString *_host; uint16_t _port; id _target; SEL _selector; + id _context; # ifdef OF_HAVE_BLOCKS of_tcp_socket_async_connect_block_t _block; # endif OFException *_exception; } @@ -83,11 +84,12 @@ - initWithSourceThread: (OFThread *)sourceThread socket: (OFTCPSocket *)socket host: (OFString *)host port: (uint16_t)port target: (id)target - selector: (SEL)selector; + selector: (SEL)selector + context: (id)context; # ifdef OF_HAVE_BLOCKS - initWithSourceThread: (OFThread *)sourceThread socket: (OFTCPSocket *)socket host: (OFString *)host port: (uint16_t)port @@ -100,10 +102,11 @@ socket: (OFTCPSocket *)socket host: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector + context: (id)context { self = [super init]; @try { _sourceThread = [sourceThread retain]; @@ -110,10 +113,11 @@ _socket = [socket retain]; _host = [host copy]; _port = port; _target = [target retain]; _selector = selector; + _context = [context retain]; } @catch (id e) { [self release]; @throw e; } @@ -148,10 +152,11 @@ { [_sourceThread release]; [_socket release]; [_host release]; [_target release]; + [_context release]; # ifdef OF_HAVE_BLOCKS [_block release]; # endif [_exception release]; @@ -165,15 +170,15 @@ # ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_socket, _exception); else { # endif - void (*func)(id, SEL, OFTCPSocket *, OFException *) = - (void (*)(id, SEL, OFTCPSocket *, OFException *))[_target - methodForSelector: _selector]; + void (*func)(id, SEL, OFTCPSocket *, id, OFException *) = + (void (*)(id, SEL, OFTCPSocket *, id, OFException *)) + [_target methodForSelector: _selector]; - func(_target, _selector, _socket, _exception); + func(_target, _selector, _socket, _context, _exception); # ifdef OF_HAVE_BLOCKS } # endif } @@ -314,20 +319,22 @@ #ifdef OF_HAVE_THREADS - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port target: (id)target selector: (SEL)selector + context: (id)context { void *pool = objc_autoreleasePoolPush(); [[[[OFTCPSocket_ConnectThread alloc] initWithSourceThread: [OFThread currentThread] socket: self host: host port: port target: target - selector: selector] autorelease] start]; + selector: selector + context: context] autorelease] start]; objc_autoreleasePoolPop(pool); } # ifdef OF_HAVE_BLOCKS @@ -572,14 +579,16 @@ return client; } - (void)asyncAcceptWithTarget: (id)target selector: (SEL)selector + context: (id)context { [OFRunLoop of_addAsyncAcceptForTCPSocket: self target: target - selector: selector]; + selector: selector + context: context]; } #ifdef OF_HAVE_BLOCKS - (void)asyncAcceptWithBlock: (of_tcp_socket_async_accept_block_t)block {